qpid-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rajith Attapattu <rajit...@gmail.com>
Subject Re: svn commit: r742267 - in /qpid/trunk/qpid/java: client/src/main/java/org/apache/qpid/jms/ common/src/main/java/org/apache/qpid/transport/ tools/src/main/java/org/apache/qpid/tools/
Date Mon, 09 Feb 2009 16:55:20 GMT
Martin,

As I mentioned I got rid of some duplicated code as the same functionality
is available in the client module. There is still a bit more.
The AMQPCallbackHandler and the UsernamePasswordCallback handler in the
common module are duplicates of the AMQCallbackHandler and
UsernamePasswordCallback defined in the client module.

It would be great if we can eliminate this duplication. The ones in the
client module passes the AMQProtocolSession in the init method while the
ones in the common module directly passes the username and password. I would
assume the AMQCallbackHandler was written with the clear intention of
supporting any type of call back that would need more info than the
user/password if we are to write our own SASL extensions.
As for the standard mechs supported in both Sun and IBM SASL impls, you can
easily get away with UsernamePasswordCallback.
So I think we could simplify the code and just use UsernamePasswordCallback.
OR if we want to preserve the ability to be extensible then we could
parametrise using generics to get there.

Either way it would be good to use a single set of classes instead of code
duplication. Once we agree on a method, I would propose that we move the
classes to the common module. This way it prevents cyclic dependency between
the common and client modules.

Regards,

Rajith

Btw,I assume the JCAProvider, DynamicSASLRegistra stuff are there for us to
register as a SASL provide in order to do the AMQPLAIN stuff?
Is the AMQPlain stuff mandated by the spec or is this done to support
OpenMQ?

On Mon, Feb 9, 2009 at 5:27 AM, Martin Ritchie <ritchiem@apache.org> wrote:

> Hi Rajith,
>
> Why not use the CallBackHandlerRegistry to automatically pick the
> mechanism from the intersection of the supported mechanisms from the
> broker and client? Or is this more to say only use GSSAPI? Might still
> be nice to be able to automatically pick an available mechanism when
> you don't actually care about it.
>
> See ConnectionStartMethodHandler.chooseMechanism in the client.
>
> Cheers
>
> Martin
>
> 2009/2/9  <rajith@apache.org>:
> > Author: rajith
> > Date: Mon Feb  9 05:14:09 2009
> > New Revision: 742267
> >
> > URL: http://svn.apache.org/viewvc?rev=742267&view=rev
> > Log:
> > This is related to QPID-1645
> > Added support to specify the sasl_mechs as a space separated list in the
> connection URL.
> > By default it will use PLAIN.
> > You could provide a list of mechs to support or force to use one GASSAPI
> or CRAM-MD5 by specifying only that in the connection URL.
> >
> > Modified:
> >
>  qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jms/BrokerDetails.java
> >
>  qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java
> >
>  qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java
> >
>  qpid/trunk/qpid/java/tools/src/main/java/org/apache/qpid/tools/JNDICheck.java
> >
> > Modified:
> qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jms/BrokerDetails.java
> > URL:
> http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jms/BrokerDetails.java?rev=742267&r1=742266&r2=742267&view=diff
> >
> ==============================================================================
> > ---
> qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jms/BrokerDetails.java
> (original)
> > +++
> qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jms/BrokerDetails.java
> Mon Feb  9 05:14:09 2009
> > @@ -35,6 +35,7 @@
> >     public static final String OPTIONS_CONNECT_TIMEOUT =
> "connecttimeout";
> >     public static final String OPTIONS_CONNECT_DELAY = "connectdelay";
> >     public static final String OPTIONS_IDLE_TIMEOUT = "idle_timeout";
> > +    public static final String OPTIONS_SASL_MECHS = "sasl_mechs";
> >     public static final int DEFAULT_PORT = 5672;
> >
> >     public static final String SOCKET = "socket";
> >
> > Modified:
> qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java
> > URL:
> http://svn.apache.org/viewvc/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java?rev=742267&r1=742266&r2=742267&view=diff
> >
> ==============================================================================
> > ---
> qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java
> (original)
> > +++
> qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/ClientDelegate.java
> Mon Feb  9 05:14:09 2009
> > @@ -46,12 +46,21 @@
> >     private String vhost;
> >     private String username;
> >     private String password;
> > -
> > -    public ClientDelegate(String vhost, String username, String
> password)
> > +    private String[] saslMechs;
> > +    private String protocol;
> > +    private String serverName;
> > +
> > +    public ClientDelegate(String vhost, String username, String
> password,String saslMechs)
> >     {
> >         this.vhost = vhost;
> >         this.username = username;
> >         this.password = password;
> > +        this.saslMechs = saslMechs.split(" ");
> > +
> > +        // Looks kinda of silly but the Sun SASL Kerberos client uses
> the
> > +        // protocol + servername as the service key.
> > +        this.protocol = System.getProperty("qpid.sasl_protocol","AMQP");
> > +        this.serverName =
> System.getProperty("qpid.sasl_server_name","localhost");
> >     }
> >
> >     public void init(Connection conn, ProtocolHeader hdr)
> > @@ -84,7 +93,7 @@
> >                 new UsernamePasswordCallbackHandler();
> >             handler.initialise(username, password);
> >             SaslClient sc = Sasl.createSaslClient
> > -                (new String[] {"PLAIN"}, null, "AMQP", "localhost",
> null, handler);
> > +                (saslMechs, null, protocol, serverName, null, handler);
> >             conn.setSaslClient(sc);
> >
> >             byte[] response = sc.hasInitialResponse() ?
> >
> > Modified:
> qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java
> > URL:
> http://svn.apache.org/viewvc/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java?rev=742267&r1=742266&r2=742267&view=diff
> >
> ==============================================================================
> > ---
> qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java
> (original)
> > +++
> qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java
> Mon Feb  9 05:14:09 2009
> > @@ -161,14 +161,19 @@
> >     {
> >         connect(host, port, vhost, username, password, false);
> >     }
> > -
> > +
> >     public void connect(String host, int port, String vhost, String
> username, String password, boolean ssl)
> >     {
> > +        connect(host, port, vhost, username, password, false,"PLAIN");
> > +    }
> > +
> > +    public void connect(String host, int port, String vhost, String
> username, String password, boolean ssl,String saslMechs)
> > +    {
> >         synchronized (lock)
> >         {
> >             state = OPENING;
> >
> > -            delegate = new ClientDelegate(vhost, username, password);
> > +            delegate = new ClientDelegate(vhost, username,
> password,saslMechs);
> >
> >             IoTransport.connect(host, port, ConnectionBinding.get(this),
> ssl);
> >             send(new ProtocolHeader(1, 0, 10));
> >
> > Modified:
> qpid/trunk/qpid/java/tools/src/main/java/org/apache/qpid/tools/JNDICheck.java
> > URL:
> http://svn.apache.org/viewvc/qpid/trunk/qpid/java/tools/src/main/java/org/apache/qpid/tools/JNDICheck.java?rev=742267&r1=742266&r2=742267&view=diff
> >
> ==============================================================================
> > ---
> qpid/trunk/qpid/java/tools/src/main/java/org/apache/qpid/tools/JNDICheck.java
> (original)
> > +++
> qpid/trunk/qpid/java/tools/src/main/java/org/apache/qpid/tools/JNDICheck.java
> Mon Feb  9 05:14:09 2009
> > @@ -187,7 +187,7 @@
> >             print("ConnectionURL:");
> >             print(factory.getConnectionURL().toString());
> >             print("FailoverPolicy");
> > -            print(new
> FailoverPolicy(factory.getConnectionURL()).toString());
> > +            print(new
> FailoverPolicy(factory.getConnectionURL(),null).toString());
> >             print("");
> >         }
> >     }
> >
> >
> >
> > ---------------------------------------------------------------------
> > Apache Qpid - AMQP Messaging Implementation
> > Project:      http://qpid.apache.org
> > Use/Interact: mailto:commits-subscribe@qpid.apache.org
> >
> >
>
>
>
> --
> Martin Ritchie
>
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:dev-subscribe@qpid.apache.org
>
>


-- 
Regards,

Rajith Attapattu
Red Hat
http://rajith.2rlabs.com/

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message