You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Houman Atashbar (JIRA)" <ji...@apache.org> on 2012/10/06 03:24:02 UTC

[jira] [Created] (NET-482) Support XOAUTH

Houman Atashbar created NET-482:
-----------------------------------

             Summary: Support XOAUTH
                 Key: NET-482
                 URL: https://issues.apache.org/jira/browse/NET-482
             Project: Commons Net
          Issue Type: Improvement
          Components: SMTP
    Affects Versions: 3.1
            Reporter: Houman Atashbar
            Priority: Minor
         Attachments: commons-net-trunk-patch.txt

It would be nice if commons-net supported XOAUTH for authentication.
I could modify the code slightly to get this working, but I thought maybe there is a better way.
If not, please have a look at my patch and see if it is worthwhile adding it to trunk.
Thanks

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (NET-482) Support XOAUTH

Posted by "Houman Atashbar (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/NET-482?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13471359#comment-13471359 ] 

Houman Atashbar commented on NET-482:
-------------------------------------

Hi Sebb, thanks for your quick reply.
I haven't looked at the requirements for other servers, but for Google itself it is different between 1.0a and 2 versions (add to this 2-legged OAuth which doesn't require a token). This is while it doesn't matter for commons-net since it uses the XOAUTH string the same way no matter what the protocol is. So, I think it would be nice if there was such a helper but I would do it conceptually separate to the authentication method itself.
I have no strong opinion on either plain or Base64, or even passing a map of key values used to create this string. If it is more consistent to accept a plain text, so be it.

                
> Support XOAUTH
> --------------
>
>                 Key: NET-482
>                 URL: https://issues.apache.org/jira/browse/NET-482
>             Project: Commons Net
>          Issue Type: Improvement
>          Components: SMTP
>    Affects Versions: 3.1
>            Reporter: Houman Atashbar
>            Priority: Minor
>         Attachments: commons-net-trunk-patch.txt
>
>
> It would be nice if commons-net supported XOAUTH for authentication.
> I could modify the code slightly to get this working, but I thought maybe there is a better way.
> If not, please have a look at my patch and see if it is worthwhile adding it to trunk.
> Thanks

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (NET-482) Support XOAUTH

Posted by "Houman Atashbar (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/NET-482?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13472893#comment-13472893 ] 

Houman Atashbar commented on NET-482:
-------------------------------------

Thanks Sebb,
This is awesome.
                
> Support XOAUTH
> --------------
>
>                 Key: NET-482
>                 URL: https://issues.apache.org/jira/browse/NET-482
>             Project: Commons Net
>          Issue Type: Improvement
>          Components: SMTP
>    Affects Versions: 3.1
>            Reporter: Houman Atashbar
>            Priority: Minor
>             Fix For: 3.2
>
>         Attachments: commons-net-trunk-patch.txt
>
>
> It would be nice if commons-net supported XOAUTH for authentication.
> I could modify the code slightly to get this working, but I thought maybe there is a better way.
> If not, please have a look at my patch and see if it is worthwhile adding it to trunk.
> Thanks

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (NET-482) Support XOAUTH

Posted by "Houman Atashbar (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/NET-482?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13470847#comment-13470847 ] 

Houman Atashbar commented on NET-482:
-------------------------------------

How to create XOAUTH strings (for Google accounts): https://developers.google.com/google-apps/gmail/oauth_protocol
                
> Support XOAUTH
> --------------
>
>                 Key: NET-482
>                 URL: https://issues.apache.org/jira/browse/NET-482
>             Project: Commons Net
>          Issue Type: Improvement
>          Components: SMTP
>    Affects Versions: 3.1
>            Reporter: Houman Atashbar
>            Priority: Minor
>         Attachments: commons-net-trunk-patch.txt
>
>
> It would be nice if commons-net supported XOAUTH for authentication.
> I could modify the code slightly to get this working, but I thought maybe there is a better way.
> If not, please have a look at my patch and see if it is worthwhile adding it to trunk.
> Thanks

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (NET-482) Support XOAUTH

Posted by "Sebb (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/NET-482?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13470970#comment-13470970 ] 

Sebb commented on NET-482:
--------------------------

It would be slightly more consistent with other methods if the code accepted a plain string and applied the Bas64 encoding itself.

Also, maybe there needs to be a method to create the string from the URL, nonce, timestamp etc?
At present, the code assumes that the string can be generated externally.
Is the XOAUTH string created in the same way for other SMTP/IMAP providers, changing only the URL etc values?
Or are there different parameters used by different servers?
                
> Support XOAUTH
> --------------
>
>                 Key: NET-482
>                 URL: https://issues.apache.org/jira/browse/NET-482
>             Project: Commons Net
>          Issue Type: Improvement
>          Components: SMTP
>    Affects Versions: 3.1
>            Reporter: Houman Atashbar
>            Priority: Minor
>         Attachments: commons-net-trunk-patch.txt
>
>
> It would be nice if commons-net supported XOAUTH for authentication.
> I could modify the code slightly to get this working, but I thought maybe there is a better way.
> If not, please have a look at my patch and see if it is worthwhile adding it to trunk.
> Thanks

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (NET-482) Support XOAUTH

Posted by "Houman Atashbar (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/NET-482?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Houman Atashbar updated NET-482:
--------------------------------

    Attachment: commons-net-trunk-patch.txt

Here is my patch.
                
> Support XOAUTH
> --------------
>
>                 Key: NET-482
>                 URL: https://issues.apache.org/jira/browse/NET-482
>             Project: Commons Net
>          Issue Type: Improvement
>          Components: SMTP
>    Affects Versions: 3.1
>            Reporter: Houman Atashbar
>            Priority: Minor
>         Attachments: commons-net-trunk-patch.txt
>
>
> It would be nice if commons-net supported XOAUTH for authentication.
> I could modify the code slightly to get this working, but I thought maybe there is a better way.
> If not, please have a look at my patch and see if it is worthwhile adding it to trunk.
> Thanks

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (NET-482) Support XOAUTH

Posted by "Sebb (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/NET-482?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sebb resolved NET-482.
----------------------

       Resolution: Fixed
    Fix Version/s: 3.2


URL: http://svn.apache.org/viewvc?rev=1396374&view=rev
Log:
NET-482 Support XOAUTH

Modified:
    commons/proper/net/trunk/src/changes/changes.xml
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/imap/AuthenticatingIMAPClient.java
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/imap/IMAPCommand.java
    commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/AuthenticatingSMTPClient.java

                
> Support XOAUTH
> --------------
>
>                 Key: NET-482
>                 URL: https://issues.apache.org/jira/browse/NET-482
>             Project: Commons Net
>          Issue Type: Improvement
>          Components: SMTP
>    Affects Versions: 3.1
>            Reporter: Houman Atashbar
>            Priority: Minor
>             Fix For: 3.2
>
>         Attachments: commons-net-trunk-patch.txt
>
>
> It would be nice if commons-net supported XOAUTH for authentication.
> I could modify the code slightly to get this working, but I thought maybe there is a better way.
> If not, please have a look at my patch and see if it is worthwhile adding it to trunk.
> Thanks

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (NET-482) Support XOAUTH

Posted by "Houman Atashbar (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/NET-482?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13470845#comment-13470845 ] 

Houman Atashbar commented on NET-482:
-------------------------------------

This is how you might use it:

public final class SMTPSMail
{

    public final static void main(String[] args)
    {
        String sender = "src.email@gmail.com";
        String senderXoauthToken = "R0VUIGh0dHBzOi8vbWFpbC5nb29nbGUuY29tL21haWwvYi9yZWxheW1lLnRpbnl3ZWJnZWFyc0BnbWFpbC5jb20vc210cC8gb2F1dGhfc2lnbmF0dXJlPSJIekpxMFlVdGlwZ3FVTHk3bWVqcCUyRktJYlg3OCUzRCIsc2NvcGU9Imh0dHBzJTNBJTJGJTJGd3d3Lmdvb2dsZWFwaXMuY29tJTJGYXV0aCUyRnVzZXJpbmZvLmVtYWlsJTIwaHR0cHMlM0ElMkYlMkZtYWlsLmdvb2dsZS5jb20lMkYiLG9hdXRoX3ZlcnNpb249IjEuMCIsb2F1dGhfbm9uY2U9IjgzODI2MDUzNyIsb2F1dGhfc2lnbmF0dXJlX21ldGhvZD0iSE1BQy1TSEExIixvYXV0aF9jb25zdW1lcl9rZXk9InJlbGF5bWUudGlueXdlYmdlYXJzLmNvbSIsb2F1dGhfdG9rZW49IjElMkZHVDA0QmxaOWVwYjk1WE10QURSSjNsNEd6b1R4YTJlR3BlYmxvZXRpT0ZvIixvYXV0aF90aW1lc3RhbXA9IjEzNDQ3NDI2MTki";
        String recipient = "destination.email@gmail.com";
        String subject = "Testing Commons Net";
        String body = "Testing at " + new Date();
        String server = "smtp.gmail.com";
        Integer port = 587;

        try
        {
            SimpleSMTPHeader header = new SimpleSMTPHeader(sender, recipient, subject);

            AuthenticatingSMTPClient client = new AuthenticatingSMTPClient();
            client.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out), true));
            client.connect(server, port);
            client.login();
            client.execTLS();
            client.auth(AuthenticatingSMTPClient.AUTH_METHOD.XOAUTH, senderXoauthToken, null);

            if (!SMTPReply.isPositiveCompletion(client.getReplyCode()))
            {
                client.disconnect();
                System.err.println("SMTP server refused connection.");
                System.exit(1);
            }

            client.setSender(sender);
            client.addRecipient(recipient);

            Writer writer = client.sendMessageData();
            if (writer != null)
            {
                writer.write(header.toString());
                writer.write(body);
                writer.close();
                client.completePendingCommand();
            }

            client.logout();

            client.disconnect();
        }
        catch (Exception e)
        {
            e.printStackTrace();
            System.exit(1);
        }
    }
}
                
> Support XOAUTH
> --------------
>
>                 Key: NET-482
>                 URL: https://issues.apache.org/jira/browse/NET-482
>             Project: Commons Net
>          Issue Type: Improvement
>          Components: SMTP
>    Affects Versions: 3.1
>            Reporter: Houman Atashbar
>            Priority: Minor
>         Attachments: commons-net-trunk-patch.txt
>
>
> It would be nice if commons-net supported XOAUTH for authentication.
> I could modify the code slightly to get this working, but I thought maybe there is a better way.
> If not, please have a look at my patch and see if it is worthwhile adding it to trunk.
> Thanks

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira