hornetq/hornetq — pull request #1406 by ghetolay (2013-11-30 17:01:22+00:00)
Title: Provide SSL information to Interceptor

My original need is to be able to identify message producer according to it's certificate.
I'm doing it using an interceptor and setting a property to each message received.

With the actual NettyConnection it's impossible to get any SSL related information so I added a getter.

Possible improvement :
- Resolve a complete different way to achieve it because interceptor are called for ALL message type.
- return more or less information (SSLEngine, Certificate chain...)
- Add this getter into Connection interface.

*Note: I found out using ChannelPipeline.get(Class handlerType) was better than ChannelPipeline.get(String name) so I've also edited NettyConnection.close() method.*

Here is what my interceptor looks like :

```Java
public class HornetQInterceptor implements Interceptor{

Logger log = Logger.getLogger(HornetQInterceptor.class);

public boolean intercept(Packet msg, RemotingConnection con)
throws HornetQException {

if(msg instanceof SessionSendMessage){
SSLSession sslSession = ((NettyConnection)con.getTransportConnection()).getSSLSession();
if(sslSession != null)
try {
((SessionSendMessage)msg).getMessage().putStringProperty("client.auth.dn", sslSession.getPeerCertificateChain()[0].getSubjectDN().getName());
} catch (SSLPeerUnverifiedException e) {
log.error(e.getMessage() + " Is NettyAcceptor's param need-client-auth set to true ?");
}
}
return true;
}
}
```