You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2015/06/07 23:02:03 UTC

svn commit: r1684078 [2/3] - in /qpid/java/trunk: client/src/main/java/org/apache/qpid/client/ client/src/main/java/org/apache/qpid/client/message/ client/src/main/java/org/apache/qpid/client/messaging/address/ client/src/main/java/org/apache/qpid/clie...

Added: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/Encrypted091MessageFactory.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/Encrypted091MessageFactory.java?rev=1684078&view=auto
==============================================================================
--- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/Encrypted091MessageFactory.java (added)
+++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/Encrypted091MessageFactory.java Sun Jun  7 21:02:02 2015
@@ -0,0 +1,232 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.client.message;
+
+import java.io.ByteArrayInputStream;
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.math.BigInteger;
+import java.nio.ByteBuffer;
+import java.security.GeneralSecurityException;
+import java.security.PrivateKey;
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.crypto.Cipher;
+import javax.crypto.CipherInputStream;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import javax.security.auth.x500.X500Principal;
+
+import org.apache.qpid.AMQException;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.framing.BasicContentHeaderProperties;
+
+public class Encrypted091MessageFactory extends AbstractJMSMessageFactory
+{
+    public static final String ENCRYPTED_0_9_1_CONTENT_TYPE = "application/qpid-0-9-1-encrypted";
+    private final MessageFactoryRegistry _messageFactoryRegistry;
+
+    public Encrypted091MessageFactory(final MessageFactoryRegistry messageFactoryRegistry)
+    {
+        _messageFactoryRegistry = messageFactoryRegistry;
+    }
+
+    @Override
+    protected AbstractJMSMessage createMessage(final AbstractAMQMessageDelegate delegate, final ByteBuffer data)
+            throws AMQException
+    {
+        SecretKeySpec secretKeySpec;
+        String algorithm;
+        byte[] initVector;
+
+        try
+        {
+            if(delegate.hasProperty(MessageEncryptionHelper.ENCRYPTION_ALGORITHM_PROPERTY))
+            {
+                algorithm = delegate.getProperty(MessageEncryptionHelper.ENCRYPTION_ALGORITHM_PROPERTY).toString();
+
+                if(delegate.hasProperty(MessageEncryptionHelper.KEY_INIT_VECTOR_PROPERTY))
+                {
+                    Object ivObj = delegate.getProperty(MessageEncryptionHelper.KEY_INIT_VECTOR_PROPERTY);
+                    if(ivObj instanceof byte[])
+                    {
+                        initVector = (byte[]) ivObj;
+                    }
+                    else
+                    {
+                        throw new AMQException("If the property '"+ MessageEncryptionHelper.KEY_INIT_VECTOR_PROPERTY+"' is present, it must contain a byte array");
+                    }
+                }
+                else
+                {
+                    initVector = null;
+                }
+                if(delegate.hasProperty(MessageEncryptionHelper.ENCRYPTED_KEYS_PROPERTY))
+                {
+                    Object keyInfoObj = delegate.getProperty(MessageEncryptionHelper.ENCRYPTED_KEYS_PROPERTY);
+                    if(keyInfoObj instanceof Collection)
+                    {
+                        secretKeySpec = getContentEncryptionKey((Collection)keyInfoObj, algorithm, _messageFactoryRegistry.getSession());
+                    }
+                    else
+                    {
+                        throw new AMQException("An encrypted message must contain the property '"+ MessageEncryptionHelper.ENCRYPTED_KEYS_PROPERTY+"'");
+                    }
+                }
+                else
+                {
+                    throw new AMQException("An encrypted message must contain the property '"+ MessageEncryptionHelper.ENCRYPTED_KEYS_PROPERTY+"'");
+                }
+
+            }
+            else
+            {
+                throw new AMQException("Encrypted message must carry the encryption algorithm in the property '"+ MessageEncryptionHelper.ENCRYPTED_KEYS_PROPERTY+"'");
+            }
+
+            Cipher cipher = Cipher.getInstance(algorithm);
+            cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, new IvParameterSpec(initVector));
+            byte[] encryptedData;
+            int offset;
+            int length;
+            if(data.hasArray())
+            {
+                encryptedData = data.array();
+                offset = data.arrayOffset() + data.position();
+                length = data.remaining();
+            }
+            else
+            {
+                encryptedData = new byte[data.remaining()];
+                data.duplicate().get(encryptedData);
+                offset = 0;
+                length = encryptedData.length;
+            }
+            final byte[] unencryptedBytes = decryptData(cipher, encryptedData, offset, length);
+
+            BasicContentHeaderProperties properties = new BasicContentHeaderProperties();
+            int payloadOffset;
+            try(ByteArrayInputStream bis = new ByteArrayInputStream(unencryptedBytes); DataInputStream dis = new DataInputStream(bis))
+            {
+                payloadOffset = properties.read(dis);
+            }
+
+            final ByteBuffer unencryptedData = ByteBuffer.wrap(unencryptedBytes, payloadOffset, unencryptedBytes.length-payloadOffset);
+
+            final AbstractAMQMessageDelegate newDelegate = new AMQMessageDelegate_0_8(properties, delegate.getDeliveryTag());
+            newDelegate.setJMSDestination(delegate.getJMSDestination());
+
+
+
+            final AbstractJMSMessageFactory unencryptedMessageFactory =
+                    _messageFactoryRegistry.getMessageFactory(properties.getContentTypeAsString());
+
+            return unencryptedMessageFactory.createMessage(newDelegate, unencryptedData);
+        }
+        catch (GeneralSecurityException | IOException e)
+        {
+            throw new AMQException("Could not decode encrypted message", e);
+        }
+
+
+    }
+
+    private byte[] decryptData(final Cipher cipher, final byte[] encryptedData, final int offset, final int length)
+            throws IOException
+    {
+        final byte[] unencryptedBytes;
+        try (CipherInputStream cipherInputStream = new CipherInputStream(new ByteArrayInputStream(encryptedData,
+                                                                                                  offset,
+                                                                                                  length), cipher))
+        {
+            byte[] buf = new byte[512];
+            int pos = 0;
+            int read;
+            while ((read = cipherInputStream.read(buf, pos, buf.length - pos)) != -1)
+            {
+                pos += read;
+                if (pos == buf.length)
+                {
+                    byte[] tmp = buf;
+                    buf = new byte[buf.length + 512];
+                    System.arraycopy(tmp, 0, buf, 0, tmp.length);
+                }
+            }
+            unencryptedBytes= new byte[pos];
+            System.arraycopy(buf, 0, unencryptedBytes, 0, pos);
+        }
+        return unencryptedBytes;
+    }
+
+    private SecretKeySpec getContentEncryptionKey(final Collection keyInfoObjList,
+                                                  final String algorithm,
+                                                  final AMQSession<?, ?> session)
+            throws AMQException, GeneralSecurityException, IOException
+    {
+
+        for(Object keyInfoObject : keyInfoObjList)
+        {
+            try
+            {
+                Iterator iter = ((Collection)keyInfoObject).iterator();
+
+                int type = ((Number)iter.next()).intValue();
+                switch(type)
+                {
+                    case 1:
+                        String keyEncryptionAlgorithm = (String) iter.next();
+                        X500Principal issuer = new X500Principal((String)iter.next());
+                        BigInteger serialNumber = new BigInteger((String)iter.next());
+                        byte[] encryptedKey = (byte[])iter.next();
+
+                        PrivateKey privateKey = getPrivateKey(session, issuer, serialNumber);
+                        if(privateKey != null)
+                        {
+                            Cipher cipher = Cipher.getInstance(keyEncryptionAlgorithm);
+                            cipher.init(Cipher.DECRYPT_MODE, privateKey);
+                            byte[] decryptedData = decryptData(cipher, encryptedKey, 0, encryptedKey.length);
+                            SecretKeySpec keySpec = new SecretKeySpec(decryptedData, algorithm.split("/")[0]);
+                            return keySpec;
+                        }
+                        break;
+                    default:
+                        throw new AMQException("Invalid format of 'x-qpid-encrypted-keys' - unknown key info type: " + type);
+
+                }
+            }
+            catch(ClassCastException e)
+            {
+                throw new AMQException("Invalid format of 'x-qpid-encrypted-keys'");
+            }
+        }
+        return null;
+    }
+
+    private PrivateKey getPrivateKey(final AMQSession<?, ?> session,
+                                     final X500Principal issuer,
+                                     final BigInteger serialNumber)
+            throws GeneralSecurityException, IOException
+    {
+        return session.getMessageEncryptionHelper().getEncryptionPrivateKey(issuer, serialNumber);
+    }
+
+}

Propchange: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/Encrypted091MessageFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/JMSBytesMessageFactory.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/JMSBytesMessageFactory.java?rev=1684078&r1=1684077&r2=1684078&view=diff
==============================================================================
--- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/JMSBytesMessageFactory.java (original)
+++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/JMSBytesMessageFactory.java Sun Jun  7 21:02:02 2015
@@ -22,21 +22,15 @@ package org.apache.qpid.client.message;
 
 import org.apache.qpid.AMQException;
 
-import javax.jms.JMSException;
 import java.nio.ByteBuffer;
 
 public class JMSBytesMessageFactory extends AbstractJMSMessageFactory
 {
-    protected AbstractJMSMessage createMessage(AMQMessageDelegate delegate, ByteBuffer data) throws AMQException
+    protected AbstractJMSMessage createMessage(AbstractAMQMessageDelegate delegate, ByteBuffer data) throws AMQException
     {
         return new JMSBytesMessage(delegate, data);
     }
 
-    public AbstractJMSMessage createMessage(AMQMessageDelegateFactory delegateFactory) throws JMSException
-    {
-        return new JMSBytesMessage(delegateFactory);
-    }
-
     // 0_10 specific
 
 }

Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/JMSMapMessageFactory.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/JMSMapMessageFactory.java?rev=1684078&r1=1684077&r2=1684078&view=diff
==============================================================================
--- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/JMSMapMessageFactory.java (original)
+++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/JMSMapMessageFactory.java Sun Jun  7 21:02:02 2015
@@ -22,17 +22,12 @@ package org.apache.qpid.client.message;
 
 import org.apache.qpid.AMQException;
 
-import javax.jms.JMSException;
 import java.nio.ByteBuffer;
 
 public class JMSMapMessageFactory extends AbstractJMSMessageFactory
 {
-    public AbstractJMSMessage createMessage(AMQMessageDelegateFactory delegateFactory) throws JMSException
-    {
-        return new JMSMapMessage(delegateFactory);
-    }
 
-    protected AbstractJMSMessage createMessage(AMQMessageDelegate delegate, ByteBuffer data) throws AMQException
+    protected AbstractJMSMessage createMessage(AbstractAMQMessageDelegate delegate, ByteBuffer data) throws AMQException
     {
         return new JMSMapMessage(delegate, data);
 

Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessageFactory.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessageFactory.java?rev=1684078&r1=1684077&r2=1684078&view=diff
==============================================================================
--- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessageFactory.java (original)
+++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessageFactory.java Sun Jun  7 21:02:02 2015
@@ -22,18 +22,13 @@ package org.apache.qpid.client.message;
 
 import org.apache.qpid.AMQException;
 
-import javax.jms.JMSException;
 import java.nio.ByteBuffer;
 
 public class JMSObjectMessageFactory extends AbstractJMSMessageFactory
 {
-    protected AbstractJMSMessage createMessage(AMQMessageDelegate delegate, ByteBuffer data) throws AMQException
+    protected AbstractJMSMessage createMessage(AbstractAMQMessageDelegate delegate, ByteBuffer data) throws AMQException
     {
         return new JMSObjectMessage(delegate, data);
     }
 
-    public AbstractJMSMessage createMessage(AMQMessageDelegateFactory delegateFactory) throws JMSException
-    {
-        return new JMSObjectMessage(delegateFactory);
-    }
 }

Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/JMSStreamMessageFactory.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/JMSStreamMessageFactory.java?rev=1684078&r1=1684077&r2=1684078&view=diff
==============================================================================
--- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/JMSStreamMessageFactory.java (original)
+++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/JMSStreamMessageFactory.java Sun Jun  7 21:02:02 2015
@@ -22,17 +22,12 @@ package org.apache.qpid.client.message;
 
 import org.apache.qpid.AMQException;
 
-import javax.jms.JMSException;
 import java.nio.ByteBuffer;
 
 public class JMSStreamMessageFactory extends AbstractJMSMessageFactory
 {
-    protected AbstractJMSMessage createMessage(AMQMessageDelegate delegate, ByteBuffer data) throws AMQException
+    protected AbstractJMSMessage createMessage(AbstractAMQMessageDelegate delegate, ByteBuffer data) throws AMQException
     {
         return new JMSStreamMessage(delegate, data);
     }
-    public AbstractJMSMessage createMessage(AMQMessageDelegateFactory delegateFactory) throws JMSException
-    {
-        return new JMSStreamMessage(delegateFactory);
-    }
 }

Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/JMSTextMessageFactory.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/JMSTextMessageFactory.java?rev=1684078&r1=1684077&r2=1684078&view=diff
==============================================================================
--- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/JMSTextMessageFactory.java (original)
+++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/JMSTextMessageFactory.java Sun Jun  7 21:02:02 2015
@@ -22,18 +22,12 @@ package org.apache.qpid.client.message;
 
 import org.apache.qpid.AMQException;
 
-import javax.jms.JMSException;
 import java.nio.ByteBuffer;
 
 public class JMSTextMessageFactory extends AbstractJMSMessageFactory
 {
 
-    public AbstractJMSMessage createMessage(AMQMessageDelegateFactory delegateFactory) throws JMSException
-    {
-        return new JMSTextMessage(delegateFactory);
-    }
-
-    protected AbstractJMSMessage createMessage(AMQMessageDelegate delegate, ByteBuffer data) throws AMQException
+    protected AbstractJMSMessage createMessage(AbstractAMQMessageDelegate delegate, ByteBuffer data) throws AMQException
     {
         return new JMSTextMessage(delegate, data);
     }

Added: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/MessageEncryptionHelper.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/MessageEncryptionHelper.java?rev=1684078&view=auto
==============================================================================
--- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/MessageEncryptionHelper.java (added)
+++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/MessageEncryptionHelper.java Sun Jun  7 21:02:02 2015
@@ -0,0 +1,426 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.client.message;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.math.BigInteger;
+import java.security.GeneralSecurityException;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidKeyException;
+import java.security.KeyStore;
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+import java.security.SecureRandom;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateExpiredException;
+import java.security.cert.CertificateNotYetValidException;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.crypto.Cipher;
+import javax.crypto.CipherInputStream;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import javax.jms.JMSException;
+import javax.security.auth.x500.X500Principal;
+
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.client.BasicMessageConsumer;
+import org.apache.qpid.transport.ConnectionSettings;
+
+public class MessageEncryptionHelper
+{
+    public static final String ENCRYPTION_ALGORITHM_PROPERTY = "x-qpid-encryption-algorithm";
+    public static final String KEY_INIT_VECTOR_PROPERTY = "x-qpid-key-init-vector";
+    public static final String ENCRYPTED_KEYS_PROPERTY = "x-qpid-encrypted-keys";
+    public static final String ENCRYPT_HEADER = "x-qpid-encrypt";
+    public static final String ENCRYPT_RECIPIENTS_HEADER = "x-qpid-encrypt-recipients";
+    public static final String UNENCRYPTED_PROPERTIES_HEADER = "x-qpid-unencrypted-properties";
+    static final int AES_KEY_SIZE_BITS = 256;
+    public static final int AES_KEY_SIZE_BYTES = AES_KEY_SIZE_BITS / 8;
+    public static final String AES_ALGORITHM = "AES";
+    public static final String DEFAULT_MESSAGE_ENCRYPTION_CIPHER_NAME = "AES/CBC/PKCS5Padding";
+    public static final int AES_INITIALIZATION_VECTOR_LENGTH = 16;
+    private final AMQSession<?, ?> _session;
+
+    private static final int KEY_TRANSPORT_RECIPIENT_INFO_TYPE = 1;
+    public static final String DEFAULT_KEY_ENCRYPTION_ALGORITHM = "RSA/ECB/OAEPWithSHA-256AndMGF1Padding";
+
+
+    private final Map<String, X509Certificate> _signingCertificateCache =
+            Collections.synchronizedMap(new LinkedHashMap<String, X509Certificate>(16,0.75f,true)
+                                        {
+                                            @Override
+                                            protected boolean removeEldestEntry(final Map.Entry<String, X509Certificate> eldest)
+                                            {
+                                                return size() > 128;
+                                            }
+                                        });
+
+    private String _keyEncryptionAlgorithm = DEFAULT_KEY_ENCRYPTION_ALGORITHM;
+    private String _messageEncryptionCipherName = DEFAULT_MESSAGE_ENCRYPTION_CIPHER_NAME;
+
+    public MessageEncryptionHelper(final AMQSession<?, ?> session)
+    {
+        _session = session;
+    }
+
+    public String getKeyEncryptionAlgorithm()
+    {
+        return _keyEncryptionAlgorithm;
+    }
+
+    public void setKeyEncryptionAlgorithm(final String keyEncryptionAlgorithm)
+    {
+        _keyEncryptionAlgorithm = keyEncryptionAlgorithm;
+    }
+
+    public String getMessageEncryptionCipherName()
+    {
+        return _messageEncryptionCipherName;
+    }
+
+    public void setMessageEncryptionCipherName(final String messageEncryptionCipherName)
+    {
+        _messageEncryptionCipherName = messageEncryptionCipherName;
+    }
+
+    public KeyStore getSigningCertificateStore() throws GeneralSecurityException, IOException
+    {
+        return _session.getAMQConnection().getConnectionSettings().getEncryptionTrustStore(new ConnectionSettings.RemoteStoreFinder()
+        {
+            @Override
+            public KeyStore getKeyStore(final String name) throws GeneralSecurityException, IOException
+            {
+                try
+                {
+                    return _session.getAMQConnection().getBrokerSuppliedTrustStore(name);
+                }
+                catch (JMSException e)
+                {
+                    throw new CertificateException("Could not load remote certificate store: '" + name  + "'", e);
+                }
+            }
+        });
+
+    }
+
+    public interface KeyTransportRecipientInfo
+    {
+        int getType();
+        String getKeyEncryptionAlgorithm();
+        String getCertIssuerPrincipal();
+        String getCertSerialNumber();
+        byte[] getEncryptedKey();
+
+        List<Object> asList();
+    }
+
+    public List<KeyTransportRecipientInfo> getKeyTransportRecipientInfo(List<String> recipients, SecretKeySpec secretKey)
+        throws GeneralSecurityException, IOException
+    {
+        List<KeyTransportRecipientInfo> result = new ArrayList<>();
+        final String keyEncryptionAlgorithm = getKeyEncryptionAlgorithm();
+        for(String recipient : recipients)
+        {
+            X509Certificate cert = getSigningCertificate(recipient.trim());
+            if(cert != null)
+            {
+
+                Cipher cipher = Cipher.getInstance(keyEncryptionAlgorithm);
+                cipher.init(Cipher.ENCRYPT_MODE, cert.getPublicKey());
+                final byte[] encryptedKey = cipher.doFinal(secretKey.getEncoded());
+
+                final String issuePrincipal = cert.getIssuerX500Principal().getName(X500Principal.CANONICAL);
+                final String serialNumber = cert.getSerialNumber().toString();
+
+                result.add(new KeyTransportRecipientInfoImpl(keyEncryptionAlgorithm,
+                                                             issuePrincipal,
+                                                             serialNumber,
+                                                             encryptedKey));
+
+            }
+            else
+            {
+                throw new CertificateException("Unable to find certificate for recipient '" + recipient +"'");
+            }
+        }
+        return result;
+    }
+
+    public X509Certificate getSigningCertificate(final String name)
+            throws GeneralSecurityException, IOException
+    {
+        X509Certificate returnVal = _signingCertificateCache.get(name);
+        if(returnVal == null)
+        {
+            KeyStore certStore = getSigningCertificateStore();
+            X500Principal requestedPrincipal;
+            List<X509Certificate> potentialCerts = new ArrayList<>();
+            try
+            {
+                requestedPrincipal = new X500Principal(name);
+            }
+            catch (IllegalArgumentException e)
+            {
+                requestedPrincipal = null;
+            }
+
+            for (String alias : Collections.list(certStore.aliases()))
+            {
+                Certificate cert = certStore.getCertificate(alias);
+                if (cert instanceof X509Certificate)
+                {
+                    X509Certificate x509Cert = (X509Certificate) cert;
+                    if (requestedPrincipal != null
+                        && requestedPrincipal.equals(x509Cert.getSubjectX500Principal()))
+                    {
+                        potentialCerts.add(x509Cert);
+                    }
+                    else if (x509Cert.getSubjectAlternativeNames() != null)
+                    {
+                        for (List<?> entry : x509Cert.getSubjectAlternativeNames())
+                        {
+                            final int type = (Integer) entry.get(0);
+                            if ((type == 1 || type == 2) && (entry.get(1).toString().trim().equals(name)))
+                            {
+                                potentialCerts.add(x509Cert);
+                                break;
+                            }
+                        }
+                    }
+
+
+                }
+            }
+
+            for (X509Certificate cert : potentialCerts)
+            {
+                try
+                {
+                    cert.checkValidity();
+                    if (returnVal == null || returnVal.getNotAfter().getTime() > cert.getNotAfter().getTime())
+                    {
+                        returnVal = cert;
+                    }
+                }
+                catch (CertificateExpiredException | CertificateNotYetValidException e)
+                {
+                    // ignore the invalid cert
+                }
+            }
+            if(returnVal != null)
+            {
+                _signingCertificateCache.put(name, returnVal);
+            }
+        }
+        return returnVal;
+    }
+
+    public PrivateKey getEncryptionPrivateKey(final X500Principal issuer,
+                                              final BigInteger serialNumber)
+            throws GeneralSecurityException, IOException
+    {
+
+        final ConnectionSettings connectionSettings = _session.getAMQConnection().getConnectionSettings();
+        KeyStore keyStore = connectionSettings.getEncryptionKeyStore();
+        if(keyStore != null)
+        {
+            for (String alias : Collections.list(keyStore.aliases()))
+            {
+                try
+                {
+
+                    final KeyStore.Entry entry = keyStore.getEntry(alias,
+                                                                   new KeyStore.PasswordProtection(connectionSettings.getEncryptionKeyStorePassword()
+                                                                                                           .toCharArray()));
+                    if (entry instanceof KeyStore.PrivateKeyEntry)
+                    {
+                        KeyStore.PrivateKeyEntry pkEntry = (KeyStore.PrivateKeyEntry) entry;
+                        if (pkEntry.getCertificate() instanceof X509Certificate)
+                        {
+                            X509Certificate cert = (X509Certificate) pkEntry.getCertificate();
+                            if (cert.getIssuerX500Principal().equals(issuer) && cert.getSerialNumber()
+                                    .equals(serialNumber))
+                            {
+                                return pkEntry.getPrivateKey();
+                            }
+                        }
+                    }
+                }
+                catch (UnsupportedOperationException e)
+                {
+                    // ignore
+                }
+            }
+        }
+        return null;
+    }
+
+    private SecureRandom _random;
+
+    public SecretKeySpec createSecretKey()
+    {
+        byte[] key = new byte[AES_KEY_SIZE_BYTES];
+        getRandomBytes(key);
+        return new SecretKeySpec(key, AES_ALGORITHM);
+    }
+
+    private void getRandomBytes(final byte[] key)
+    {
+        synchronized (this)
+        {
+
+            if(_random == null)
+            {
+                _random = new SecureRandom();
+            }
+            _random.nextBytes(key);
+        }
+    }
+
+    public byte[] getInitialisationVector()
+    {
+        byte[] ivbytes = new byte[AES_INITIALIZATION_VECTOR_LENGTH];
+        getRandomBytes(ivbytes);
+        return ivbytes;
+    }
+
+    public byte[] readFromCipherStream(final byte[] unencryptedBytes, int offset, int length, final Cipher cipher)
+            throws IOException
+    {
+        final byte[] encryptedBytes;
+        try (CipherInputStream cipherInputStream = new CipherInputStream(new ByteArrayInputStream(unencryptedBytes,
+                                                                                                  offset,
+                                                                                                  length), cipher))
+        {
+            byte[] buf = new byte[512];
+            int pos = 0;
+            int read;
+            while ((read = cipherInputStream.read(buf, pos, buf.length - pos)) != -1)
+            {
+                pos += read;
+                if (pos == buf.length)
+                {
+                    byte[] tmp = buf;
+                    buf = new byte[buf.length + 512];
+                    System.arraycopy(tmp, 0, buf, 0, tmp.length);
+                }
+            }
+            encryptedBytes = new byte[pos];
+            System.arraycopy(buf, 0, encryptedBytes, 0, pos);
+        }
+        return encryptedBytes;
+    }
+
+    public byte[] readFromCipherStream(final byte[] unencryptedBytes, final Cipher cipher, final AMQSession amqSession) throws IOException
+    {
+        return readFromCipherStream(unencryptedBytes, 0, unencryptedBytes.length, cipher);
+    }
+
+    public byte[] encrypt(SecretKeySpec secretKey,
+                          final byte[] unencryptedBytes,
+                          byte[] ivbytes)
+    {
+        try
+        {
+            Cipher cipher = Cipher.getInstance(getMessageEncryptionCipherName());
+            cipher.init(Cipher.ENCRYPT_MODE, secretKey, new IvParameterSpec(ivbytes));
+            return readFromCipherStream(unencryptedBytes, cipher, _session);
+        }
+        catch (IOException | InvalidAlgorithmParameterException | InvalidKeyException | NoSuchAlgorithmException | NoSuchPaddingException e)
+        {
+            throw new IllegalArgumentException("Unable to encrypt secret with secret key. Cipher: "
+                                               + getMessageEncryptionCipherName()
+                                               + " . Key of type " + secretKey.getAlgorithm()
+                                               + " size " + secretKey.getEncoded().length, e);
+        }
+    }
+
+    private static class KeyTransportRecipientInfoImpl implements KeyTransportRecipientInfo
+    {
+        private final String _keyEncryptionAlgorithm;
+        private final String _issuePrincipal;
+        private final String _serialNumber;
+        private final byte[] _encryptedKey;
+
+        public KeyTransportRecipientInfoImpl(final String keyEncryptionAlgorithm,
+                                             final String issuePrincipal,
+                                             final String serialNumber,
+                                             final byte[] encryptedKey)
+        {
+            _keyEncryptionAlgorithm = keyEncryptionAlgorithm;
+            _issuePrincipal = issuePrincipal;
+            _serialNumber = serialNumber;
+            _encryptedKey = encryptedKey;
+        }
+
+        @Override
+        public int getType()
+        {
+            return KEY_TRANSPORT_RECIPIENT_INFO_TYPE;
+        }
+
+        @Override
+        public String getKeyEncryptionAlgorithm()
+        {
+            return _keyEncryptionAlgorithm;
+        }
+
+        @Override
+        public String getCertIssuerPrincipal()
+        {
+            return _issuePrincipal;
+        }
+
+        @Override
+        public String getCertSerialNumber()
+        {
+            return _serialNumber;
+        }
+
+        @Override
+        public byte[] getEncryptedKey()
+        {
+            return _encryptedKey;
+        }
+
+        @Override
+        public List<Object> asList()
+        {
+            List<Object> result = new ArrayList<>();
+
+            result.add(KEY_TRANSPORT_RECIPIENT_INFO_TYPE);
+            result.add(_keyEncryptionAlgorithm);
+            result.add(_issuePrincipal);
+            result.add(_serialNumber);
+            result.add(_encryptedKey);
+            return result;
+        }
+    }
+}

Propchange: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/MessageEncryptionHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/MessageFactoryRegistry.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/MessageFactoryRegistry.java?rev=1684078&r1=1684077&r2=1684078&view=diff
==============================================================================
--- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/MessageFactoryRegistry.java (original)
+++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/message/MessageFactoryRegistry.java Sun Jun  7 21:02:02 2015
@@ -31,6 +31,7 @@ import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.AMQSession;
 import org.apache.qpid.client.AMQSession_0_8;
 import org.apache.qpid.client.AMQTopic;
 import org.apache.qpid.framing.AMQShortString;
@@ -47,19 +48,25 @@ public class MessageFactoryRegistry
      */
     private final Logger _logger = LoggerFactory.getLogger(getClass());
 
-    private final Map<String, MessageFactory> _mimeStringToFactoryMap = new HashMap<String, MessageFactory>();
-    private final Map<AMQShortString, MessageFactory> _mimeShortStringToFactoryMap =
-            new HashMap<AMQShortString, MessageFactory>();
-    private final MessageFactory _default = new JMSBytesMessageFactory();
+    private final Map<String, AbstractJMSMessageFactory> _mimeStringToFactoryMap = new HashMap<>();
+
+    private final AbstractJMSMessageFactory _default = new JMSBytesMessageFactory();
+    private final AMQSession<?, ?> _session;
+
+    public MessageFactoryRegistry(final AMQSession<?, ?> session)
+    {
+        _session = session;
+    }
 
     /**
      * Construct a new registry with the default message factories registered
      *
      * @return a message factory registry
+     * @param session
      */
-    public static MessageFactoryRegistry newDefaultRegistry()
+    public static MessageFactoryRegistry newDefaultRegistry(final AMQSession<?, ?> session)
     {
-        MessageFactoryRegistry mf = new MessageFactoryRegistry();
+        MessageFactoryRegistry mf = new MessageFactoryRegistry(session);
         mf.registerFactory(JMSMapMessage.MIME_TYPE, new JMSMapMessageFactory());
         mf.registerFactory("text/plain", new JMSTextMessageFactory());
         mf.registerFactory("text/xml", new JMSTextMessageFactory());
@@ -68,28 +75,18 @@ public class MessageFactoryRegistry
         mf.registerFactory(JMSStreamMessage.MIME_TYPE, new JMSStreamMessageFactory());
         mf.registerFactory(AMQPEncodedMapMessage.MIME_TYPE, new AMQPEncodedMapMessageFactory());
         mf.registerFactory(AMQPEncodedListMessage.MIME_TYPE, new AMQPEncodedListMessageFactory());
-        mf.registerFactory(null, mf._default);
 
+        mf.registerFactory(Encrypted091MessageFactory.ENCRYPTED_0_9_1_CONTENT_TYPE, new Encrypted091MessageFactory(mf));
+        mf.registerFactory(Encrypted010MessageFactory.ENCRYPTED_0_10_CONTENT_TYPE, new Encrypted010MessageFactory(mf));
+
+        mf.registerFactory(null, mf._default);
         return mf;
     }
 
 
-    public void registerFactory(String mimeType, MessageFactory mf)
+    public void registerFactory(String mimeType, AbstractJMSMessageFactory mf)
     {
-        if (mf == null)
-        {
-            throw new IllegalArgumentException("Message factory must not be null");
-        }
-
         _mimeStringToFactoryMap.put(mimeType, mf);
-        _mimeShortStringToFactoryMap.put(new AMQShortString(mimeType), mf);
-    }
-
-    public MessageFactory deregisterFactory(String mimeType)
-    {
-        _mimeShortStringToFactoryMap.remove(new AMQShortString(mimeType));
-
-        return _mimeStringToFactoryMap.remove(mimeType);
     }
 
     /**
@@ -123,13 +120,19 @@ public class MessageFactoryRegistry
         AMQShortString contentTypeShortString = properties.getContentType();
         contentTypeShortString = (contentTypeShortString == null) ? new AMQShortString(JMSBytesMessage.MIME_TYPE) : contentTypeShortString;
 
-        MessageFactory mf = _mimeShortStringToFactoryMap.get(contentTypeShortString);
+        AbstractJMSMessageFactory mf = getMessageFactory(AMQShortString.toString(contentTypeShortString));
+
+        return mf.createMessage(deliveryTag, redelivered, contentHeader, exchange, routingKey, bodies, queueDestinationCache, topicDestinationCache, addressType);
+    }
+
+    AbstractJMSMessageFactory getMessageFactory(final String contentTypeShortString)
+    {
+        AbstractJMSMessageFactory mf = _mimeStringToFactoryMap.get(contentTypeShortString);
         if (mf == null)
         {
             mf = _default;
         }
-
-        return mf.createMessage(deliveryTag, redelivered, contentHeader, exchange, routingKey, bodies, queueDestinationCache, topicDestinationCache, addressType);
+        return mf;
     }
 
     public AbstractJMSMessage createMessage(MessageTransfer transfer) throws AMQException, JMSException
@@ -146,11 +149,7 @@ public class MessageFactoryRegistry
         {
            messageType = mprop.getContentType();
         }
-        MessageFactory mf = _mimeStringToFactoryMap.get(messageType);
-        if (mf == null)
-        {
-            mf = _default;
-        }
+        AbstractJMSMessageFactory mf = getMessageFactory(messageType);
 
         boolean redelivered = false;
         DeliveryProperties deliverProps;
@@ -165,20 +164,13 @@ public class MessageFactoryRegistry
                                 transfer.getBody());
     }
 
-
-    public AbstractJMSMessage createMessage(AMQMessageDelegateFactory delegateFactory, String mimeType) throws AMQException, JMSException
+    public AMQSession<?, ?> getSession()
     {
-        if (mimeType == null)
-        {
-            throw new IllegalArgumentException("Mime type must not be null");
-        }
-
-        MessageFactory mf = _mimeStringToFactoryMap.get(mimeType);
-        if (mf == null)
-        {
-            mf = _default;
-        }
+        return _session;
+    }
 
-        return mf.createMessage(delegateFactory);
+    AbstractJMSMessageFactory getDefaultFactory()
+    {
+        return _default;
     }
 }

Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/messaging/address/AddressHelper.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/messaging/address/AddressHelper.java?rev=1684078&r1=1684077&r2=1684078&view=diff
==============================================================================
--- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/messaging/address/AddressHelper.java (original)
+++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/messaging/address/AddressHelper.java Sun Jun  7 21:02:02 2015
@@ -45,6 +45,10 @@ public class AddressHelper
     public static final String X_BINDINGS = "x-bindings";
     public static final String X_SUBSCRIBES = "x-subscribes";
     public static final String X_SUBSCRIBE = "x-subscribe";
+
+    public static final String X_SEND_ENCRYPTED = "x-send-encrypted";
+    public static final String X_ENCRYPTED_RECIPIENTS = "x-encrypted-recipients";
+
     public static final String CREATE = "create";
     public static final String ASSERT = "assert";
     public static final String DELETE = "delete";
@@ -75,6 +79,8 @@ public class AddressHelper
     private Map _addressPropMap;
     private Map _nodePropMap;
     private Map _linkPropMap;
+    private boolean _sendEncrypted;
+    private String _encryptedRecipients;
 
     public AddressHelper(Address address)
     {
@@ -304,4 +310,15 @@ public class AddressHelper
 
         return link;
     }
+
+    public boolean getSendEncrypted()
+    {
+        return Boolean.TRUE.equals(_addressPropAccess.getBoolean(X_SEND_ENCRYPTED));
+
+    }
+
+    public String getEncryptedRecipients()
+    {
+        return _addressPropAccess.getString(X_ENCRYPTED_RECIPIENTS);
+    }
 }

Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/url/URLParser.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/url/URLParser.java?rev=1684078&r1=1684077&r2=1684078&view=diff
==============================================================================
--- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/url/URLParser.java (original)
+++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/url/URLParser.java Sun Jun  7 21:02:02 2015
@@ -21,7 +21,7 @@
 package org.apache.qpid.client.url;
 
 
-import org.apache.qpid.client.AMQBrokerDetails;
+import org.apache.qpid.client.BrokerDetails;
 import org.apache.qpid.client.AMQConnectionFactory;
 import org.apache.qpid.client.AMQConnectionURL;
 import org.apache.qpid.url.URLHelper;
@@ -197,7 +197,9 @@ public class URLParser
             {
                 String broker = st.nextToken();
 
-                _url.addBrokerDetails(new AMQBrokerDetails(broker));
+                final BrokerDetails brokerDetails = new BrokerDetails(broker);
+                brokerDetails.setConnectionUrl(_url);
+                _url.addBrokerDetails(brokerDetails);
             }
 
             _url.getOptions().remove(AMQConnectionURL.OPTIONS_BROKERLIST);

Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/client/url/URLParser_0_10.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/client/url/URLParser_0_10.java?rev=1684078&r1=1684077&r2=1684078&view=diff
==============================================================================
--- qpid/java/trunk/client/src/main/java/org/apache/qpid/client/url/URLParser_0_10.java (original)
+++ qpid/java/trunk/client/src/main/java/org/apache/qpid/client/url/URLParser_0_10.java Sun Jun  7 21:02:02 2015
@@ -17,8 +17,7 @@
  */
 package org.apache.qpid.client.url;
 
-import org.apache.qpid.client.AMQBrokerDetails;
-import org.apache.qpid.jms.BrokerDetails;
+import org.apache.qpid.client.BrokerDetails;
 
 import java.net.MalformedURLException;
 import java.util.ArrayList;
@@ -196,7 +195,7 @@ public class URLParser_0_10
 
     private URLParserState startAddress()
     {
-        _currentBroker = new AMQBrokerDetails();
+        _currentBroker = new BrokerDetails();
 
         for (int j = _index; j < _url.length; j++)
         {

Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java?rev=1684078&r1=1684077&r2=1684078&view=diff
==============================================================================
--- qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java (original)
+++ qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java Sun Jun  7 21:02:02 2015
@@ -22,6 +22,8 @@ package org.apache.qpid.jms;
 
 import java.util.List;
 
+import org.apache.qpid.client.BrokerDetails;
+
 /**
  Connection URL format
  {@literal amqp://[user:pass@][clientid]/virtualhost?brokerlist='tcp://host:port?option=\'value\'&option=\'value\';tcp://host:port/virtualpath?option=\'value\''&failover='method?option=\'value\'&option='value''" }

Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java?rev=1684078&r1=1684077&r2=1684078&view=diff
==============================================================================
--- qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java (original)
+++ qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/FailoverPolicy.java Sun Jun  7 21:02:02 2015
@@ -23,6 +23,7 @@ package org.apache.qpid.jms;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.apache.qpid.client.BrokerDetails;
 import org.apache.qpid.jms.failover.FailoverExchangeMethod;
 import org.apache.qpid.jms.failover.FailoverMethod;
 import org.apache.qpid.jms.failover.FailoverRoundRobinServers;

Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/failover/FailoverExchangeMethod.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/failover/FailoverExchangeMethod.java?rev=1684078&r1=1684077&r2=1684078&view=diff
==============================================================================
--- qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/failover/FailoverExchangeMethod.java (original)
+++ qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/failover/FailoverExchangeMethod.java Sun Jun  7 21:02:02 2015
@@ -24,8 +24,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.qpid.client.AMQAnyDestination;
-import org.apache.qpid.client.AMQBrokerDetails;
-import org.apache.qpid.jms.BrokerDetails;
+import org.apache.qpid.client.BrokerDetails;
 import org.apache.qpid.jms.Connection;
 import org.apache.qpid.jms.ConnectionURL;
 
@@ -132,11 +131,10 @@ public class FailoverExchangeMethod impl
                     String[] tokens = url.split(":");
                     if (tokens[0].equalsIgnoreCase(_originalBrokerDetail.getTransport()))
                     {
-                        BrokerDetails broker = new AMQBrokerDetails();
+                        BrokerDetails broker = new BrokerDetails(_originalBrokerDetail);
                         broker.setTransport(tokens[0]);
                         broker.setHost(tokens[1]);
                         broker.setPort(Integer.parseInt(tokens[2]));
-                        broker.setProperties(_originalBrokerDetail.getProperties());
                         brokerList.add(broker);
                         
                         if (currentBrokerIP.equals(broker.getHost()) && 

Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/failover/FailoverMethod.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/failover/FailoverMethod.java?rev=1684078&r1=1684077&r2=1684078&view=diff
==============================================================================
--- qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/failover/FailoverMethod.java (original)
+++ qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/failover/FailoverMethod.java Sun Jun  7 21:02:02 2015
@@ -21,7 +21,7 @@
 
 package org.apache.qpid.jms.failover;
 
-import org.apache.qpid.jms.BrokerDetails;
+import org.apache.qpid.client.BrokerDetails;
 
 public interface FailoverMethod
 {

Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/failover/FailoverRoundRobinServers.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/failover/FailoverRoundRobinServers.java?rev=1684078&r1=1684077&r2=1684078&view=diff
==============================================================================
--- qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/failover/FailoverRoundRobinServers.java (original)
+++ qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/failover/FailoverRoundRobinServers.java Sun Jun  7 21:02:02 2015
@@ -23,7 +23,7 @@ package org.apache.qpid.jms.failover;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import org.apache.qpid.jms.BrokerDetails;
+import org.apache.qpid.client.BrokerDetails;
 import org.apache.qpid.jms.ConnectionURL;
 
 public class FailoverRoundRobinServers implements FailoverMethod

Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java?rev=1684078&r1=1684077&r2=1684078&view=diff
==============================================================================
--- qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java (original)
+++ qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/failover/FailoverSingleServer.java Sun Jun  7 21:02:02 2015
@@ -23,7 +23,7 @@ package org.apache.qpid.jms.failover;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import org.apache.qpid.jms.BrokerDetails;
+import org.apache.qpid.client.BrokerDetails;
 import org.apache.qpid.jms.ConnectionURL;
 
 public class FailoverSingleServer implements FailoverMethod

Modified: qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/failover/NoFailover.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/failover/NoFailover.java?rev=1684078&r1=1684077&r2=1684078&view=diff
==============================================================================
--- qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/failover/NoFailover.java (original)
+++ qpid/java/trunk/client/src/main/java/org/apache/qpid/jms/failover/NoFailover.java Sun Jun  7 21:02:02 2015
@@ -20,7 +20,7 @@
  */
 package org.apache.qpid.jms.failover;
 
-import org.apache.qpid.jms.BrokerDetails;
+import org.apache.qpid.client.BrokerDetails;
 import org.apache.qpid.jms.ConnectionURL;
 
 /**

Modified: qpid/java/trunk/client/src/test/java/org/apache/qpid/client/AMQConnectionFactoryTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/test/java/org/apache/qpid/client/AMQConnectionFactoryTest.java?rev=1684078&r1=1684077&r2=1684078&view=diff
==============================================================================
--- qpid/java/trunk/client/src/test/java/org/apache/qpid/client/AMQConnectionFactoryTest.java (original)
+++ qpid/java/trunk/client/src/test/java/org/apache/qpid/client/AMQConnectionFactoryTest.java Sun Jun  7 21:02:02 2015
@@ -30,8 +30,6 @@ import javax.jms.JMSException;
 
 import junit.framework.TestCase;
 
-import org.apache.qpid.client.AMQConnectionFactory;
-import org.apache.qpid.jms.BrokerDetails;
 import org.apache.qpid.jms.ConnectionURL;
 
 public class AMQConnectionFactoryTest extends TestCase

Modified: qpid/java/trunk/client/src/test/java/org/apache/qpid/client/MockAMQConnection.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/test/java/org/apache/qpid/client/MockAMQConnection.java?rev=1684078&r1=1684077&r2=1684078&view=diff
==============================================================================
--- qpid/java/trunk/client/src/test/java/org/apache/qpid/client/MockAMQConnection.java (original)
+++ qpid/java/trunk/client/src/test/java/org/apache/qpid/client/MockAMQConnection.java Sun Jun  7 21:02:02 2015
@@ -25,7 +25,6 @@ import java.io.IOException;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.state.AMQState;
 import org.apache.qpid.framing.ProtocolVersion;
-import org.apache.qpid.jms.BrokerDetails;
 import org.apache.qpid.url.URLSyntaxException;
 
 public class MockAMQConnection extends AMQConnection

Added: qpid/java/trunk/client/src/test/java/org/apache/qpid/client/message/Encrypted010MessageFactoryTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/test/java/org/apache/qpid/client/message/Encrypted010MessageFactoryTest.java?rev=1684078&view=auto
==============================================================================
--- qpid/java/trunk/client/src/test/java/org/apache/qpid/client/message/Encrypted010MessageFactoryTest.java (added)
+++ qpid/java/trunk/client/src/test/java/org/apache/qpid/client/message/Encrypted010MessageFactoryTest.java Sun Jun  7 21:02:02 2015
@@ -0,0 +1,156 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.client.message;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.matches;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.FileInputStream;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+import java.security.KeyStore;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import javax.security.auth.x500.X500Principal;
+
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.test.utils.TestSSLConstants;
+import org.apache.qpid.transport.ConnectionSettings;
+import org.apache.qpid.transport.DeliveryProperties;
+import org.apache.qpid.transport.MessageProperties;
+import org.apache.qpid.transport.codec.BBEncoder;
+
+public class Encrypted010MessageFactoryTest extends QpidTestCase
+{
+    public static final String TEXT_MESSAGE_CONTENT = "Test message";
+    private Encrypted010MessageFactory _messageFactory;
+    private byte[] _data = TEXT_MESSAGE_CONTENT.getBytes(StandardCharsets.UTF_8);;
+    private MessageProperties _messageProps;
+    private DeliveryProperties _deliveryProps;
+
+    byte[] _secretKeyEncoded = "secretkeyencoded0123456890abcdef".getBytes(StandardCharsets.US_ASCII);
+    byte[] _initializeVector = "initializevector".getBytes(StandardCharsets.US_ASCII);
+    private byte[] _unencrypted;
+    private byte[] _encryptedMessage;
+    private MessageEncryptionHelper _encryptionHelper;
+    private SecretKeySpec _secretKeySpec;
+    private KeyStore _keyStore;
+    private MessageFactoryRegistry _messageFactoryRegistry;
+
+    @Override
+    public void setUp() throws Exception
+    {
+        super.setUp();
+        final AMQSession session = mock(AMQSession.class);
+        _messageFactoryRegistry = MessageFactoryRegistry.newDefaultRegistry(session);
+        _messageFactory = new Encrypted010MessageFactory(_messageFactoryRegistry);
+
+
+        _messageProps = new MessageProperties();
+        final HashMap<String, Object> headers = new HashMap<>();
+        _messageProps.setApplicationHeaders(headers);
+        _deliveryProps = new DeliveryProperties();
+        _messageProps.setContentType("text/plain");
+        BBEncoder encoder = new BBEncoder(1024);
+        encoder.writeStruct32(_deliveryProps);
+        encoder.writeStruct32(_messageProps);
+        ByteBuffer buffer = encoder.buffer();
+
+        final int payloadOffset = buffer.remaining();
+        _unencrypted = new byte[payloadOffset + _data.length];
+        buffer.get(_unencrypted,0, payloadOffset);
+        System.arraycopy(_data,0,_unencrypted,payloadOffset,_data.length);
+
+        _secretKeySpec = new SecretKeySpec(_secretKeyEncoded, "AES");
+        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
+        cipher.init(Cipher.ENCRYPT_MODE, _secretKeySpec, new IvParameterSpec(_initializeVector));
+        _encryptedMessage = cipher.doFinal(_unencrypted);
+        _keyStore = KeyStore.getInstance("JKS");
+        _keyStore.load(new FileInputStream(TestSSLConstants.KEYSTORE), TestSSLConstants.KEYSTORE_PASSWORD.toCharArray());
+
+        final AMQConnection connection = mock(AMQConnection.class);
+        final ConnectionSettings settings = mock(ConnectionSettings.class);
+
+        when(session.getAMQConnection()).thenReturn(connection);
+        when(connection.getConnectionSettings()).thenReturn(settings);
+        when(settings.getEncryptionTrustStore(any(ConnectionSettings.RemoteStoreFinder.class))).thenReturn(_keyStore);
+        when(settings.getEncryptionKeyStore()).thenReturn(_keyStore);
+        when(settings.getEncryptionKeyStorePassword()).thenReturn(TestSSLConstants.KEYSTORE_PASSWORD);
+
+        _encryptionHelper = new MessageEncryptionHelper(session);
+        when(session.getMessageEncryptionHelper()).thenReturn(_encryptionHelper);
+
+    }
+
+    public void testDecryptsMessage() throws Exception
+    {
+        if(isStrongEncryptionEnabled())
+        {
+            final MessageProperties messageProps = new MessageProperties();
+            final DeliveryProperties deliveryProps = new DeliveryProperties();
+            final HashMap<String, Object> headers = new HashMap<>();
+
+            final List<MessageEncryptionHelper.KeyTransportRecipientInfo> recipientInfo =
+                    _encryptionHelper.getKeyTransportRecipientInfo(Collections.singletonList(((X509Certificate) _keyStore
+                            .getCertificate(
+                                    "app1")).getSubjectX500Principal().getName(
+                            X500Principal.CANONICAL)), _secretKeySpec);
+
+            List<List<Object>> recipientHeader = new ArrayList<>();
+            for (MessageEncryptionHelper.KeyTransportRecipientInfo info : recipientInfo)
+            {
+                recipientHeader.add(info.asList());
+            }
+
+
+            headers.put(MessageEncryptionHelper.ENCRYPTION_ALGORITHM_PROPERTY,
+                        MessageEncryptionHelper.DEFAULT_MESSAGE_ENCRYPTION_CIPHER_NAME);
+            headers.put(MessageEncryptionHelper.ENCRYPTED_KEYS_PROPERTY, recipientHeader);
+            headers.put(MessageEncryptionHelper.KEY_INIT_VECTOR_PROPERTY, _initializeVector);
+            messageProps.setApplicationHeaders(headers);
+
+            final AbstractJMSMessage message =
+                    _messageFactory.createMessage(new AMQMessageDelegate_0_10(messageProps, deliveryProps, 1l),
+                                                  ByteBuffer.wrap(_encryptedMessage));
+
+
+            assertTrue("message is not a text message", message instanceof JMSTextMessage);
+            assertEquals("Message content not as expected", TEXT_MESSAGE_CONTENT, ((JMSTextMessage) message).getText());
+        }
+    }
+
+    private boolean isStrongEncryptionEnabled() throws NoSuchAlgorithmException
+    {
+        return Cipher.getMaxAllowedKeyLength("AES")>=256;
+    }
+}

Propchange: qpid/java/trunk/client/src/test/java/org/apache/qpid/client/message/Encrypted010MessageFactoryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: qpid/java/trunk/client/src/test/java/org/apache/qpid/client/message/Encrypted091MessageFactoryTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/test/java/org/apache/qpid/client/message/Encrypted091MessageFactoryTest.java?rev=1684078&view=auto
==============================================================================
--- qpid/java/trunk/client/src/test/java/org/apache/qpid/client/message/Encrypted091MessageFactoryTest.java (added)
+++ qpid/java/trunk/client/src/test/java/org/apache/qpid/client/message/Encrypted091MessageFactoryTest.java Sun Jun  7 21:02:02 2015
@@ -0,0 +1,150 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.client.message;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.FileInputStream;
+import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
+import java.security.KeyStore;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import javax.security.auth.x500.X500Principal;
+
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.framing.BasicContentHeaderProperties;
+import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.test.utils.TestSSLConstants;
+import org.apache.qpid.transport.ConnectionSettings;
+import org.apache.qpid.transport.DeliveryProperties;
+import org.apache.qpid.transport.MessageProperties;
+import org.apache.qpid.transport.codec.BBEncoder;
+import org.apache.qpid.util.BytesDataOutput;
+
+public class Encrypted091MessageFactoryTest extends QpidTestCase
+{
+    public static final String TEXT_MESSAGE_CONTENT = "Test message";
+    private Encrypted091MessageFactory _messageFactory;
+    private byte[] _data = TEXT_MESSAGE_CONTENT.getBytes(StandardCharsets.UTF_8);;
+    private BasicContentHeaderProperties _props;
+
+    byte[] _secretKeyEncoded = "secretkeyencoded0123456890abcdef".getBytes(StandardCharsets.US_ASCII);
+    byte[] _initializeVector = "initializevector".getBytes(StandardCharsets.US_ASCII);
+    private byte[] _unencrypted;
+    private byte[] _encryptedMessage;
+    private MessageEncryptionHelper _encryptionHelper;
+    private SecretKeySpec _secretKeySpec;
+    private KeyStore _keyStore;
+    private MessageFactoryRegistry _messageFactoryRegistry;
+
+    @Override
+    public void setUp() throws Exception
+    {
+        super.setUp();
+        final AMQSession session = mock(AMQSession.class);
+        _messageFactoryRegistry = MessageFactoryRegistry.newDefaultRegistry(session);
+        _messageFactory = new Encrypted091MessageFactory(_messageFactoryRegistry);
+
+
+        _props = new BasicContentHeaderProperties();
+        _props.setContentType("text/plain");
+
+        final int headerLength = _props.getPropertyListSize() + 2;
+        _unencrypted = new byte[headerLength + _data.length];
+        BytesDataOutput output = new BytesDataOutput(_unencrypted);
+        output.writeShort((short) (_props.getPropertyFlags() & 0xffff));
+        _props.writePropertyListPayload(output);
+
+
+
+        System.arraycopy(_data,0,_unencrypted,headerLength,_data.length);
+
+        _secretKeySpec = new SecretKeySpec(_secretKeyEncoded, "AES");
+        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
+        cipher.init(Cipher.ENCRYPT_MODE, _secretKeySpec, new IvParameterSpec(_initializeVector));
+        _encryptedMessage = cipher.doFinal(_unencrypted);
+        _keyStore = KeyStore.getInstance("JKS");
+        _keyStore.load(new FileInputStream(TestSSLConstants.KEYSTORE), TestSSLConstants.KEYSTORE_PASSWORD.toCharArray());
+
+        final AMQConnection connection = mock(AMQConnection.class);
+        final ConnectionSettings settings = mock(ConnectionSettings.class);
+
+        when(session.getAMQConnection()).thenReturn(connection);
+        when(connection.getConnectionSettings()).thenReturn(settings);
+        when(settings.getEncryptionTrustStore(any(ConnectionSettings.RemoteStoreFinder.class))).thenReturn(_keyStore);
+        when(settings.getEncryptionKeyStore()).thenReturn(_keyStore);
+        when(settings.getEncryptionKeyStorePassword()).thenReturn(TestSSLConstants.KEYSTORE_PASSWORD);
+
+        _encryptionHelper = new MessageEncryptionHelper(session);
+        when(session.getMessageEncryptionHelper()).thenReturn(_encryptionHelper);
+
+    }
+
+    public void testDecryptsMessage() throws Exception
+    {
+        if(isStrongEncryptionEnabled())
+        {
+            final List<MessageEncryptionHelper.KeyTransportRecipientInfo> recipientInfo =
+                    _encryptionHelper.getKeyTransportRecipientInfo(Collections.singletonList(((X509Certificate) _keyStore
+                            .getCertificate(
+                                    "app1")).getSubjectX500Principal().getName(
+                            X500Principal.CANONICAL)), _secretKeySpec);
+
+            List<List<Object>> recipientHeader = new ArrayList<>();
+            for (MessageEncryptionHelper.KeyTransportRecipientInfo info : recipientInfo)
+            {
+                recipientHeader.add(info.asList());
+            }
+
+            BasicContentHeaderProperties props = new BasicContentHeaderProperties();
+            props.getHeaders().setObject(MessageEncryptionHelper.ENCRYPTION_ALGORITHM_PROPERTY,
+                                         MessageEncryptionHelper.DEFAULT_MESSAGE_ENCRYPTION_CIPHER_NAME);
+            props.getHeaders().setObject(MessageEncryptionHelper.ENCRYPTED_KEYS_PROPERTY, recipientHeader);
+            props.getHeaders().setObject(MessageEncryptionHelper.KEY_INIT_VECTOR_PROPERTY, _initializeVector);
+
+            final AbstractJMSMessage message =
+                    _messageFactory.createMessage(new AMQMessageDelegate_0_8(props, 1l),
+                                                  ByteBuffer.wrap(_encryptedMessage));
+
+
+            assertTrue("message is not a text message", message instanceof JMSTextMessage);
+            assertEquals("Message content not as expected", TEXT_MESSAGE_CONTENT, ((JMSTextMessage) message).getText());
+        }
+    }
+
+    private boolean isStrongEncryptionEnabled() throws NoSuchAlgorithmException
+    {
+        return Cipher.getMaxAllowedKeyLength("AES")>=256;
+    }
+
+}

Propchange: qpid/java/trunk/client/src/test/java/org/apache/qpid/client/message/Encrypted091MessageFactoryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: qpid/java/trunk/client/src/test/java/org/apache/qpid/jms/FailoverPolicyTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/test/java/org/apache/qpid/jms/FailoverPolicyTest.java?rev=1684078&r1=1684077&r2=1684078&view=diff
==============================================================================
--- qpid/java/trunk/client/src/test/java/org/apache/qpid/jms/FailoverPolicyTest.java (original)
+++ qpid/java/trunk/client/src/test/java/org/apache/qpid/jms/FailoverPolicyTest.java Sun Jun  7 21:02:02 2015
@@ -22,6 +22,7 @@ package org.apache.qpid.jms;
 
 import junit.framework.TestCase;
 
+import org.apache.qpid.client.BrokerDetails;
 import org.apache.qpid.client.AMQConnectionURL;
 import org.apache.qpid.jms.failover.FailoverExchangeMethod;
 import org.apache.qpid.jms.failover.FailoverMethod;

Modified: qpid/java/trunk/client/src/test/java/org/apache/qpid/test/unit/client/BrokerDetails/BrokerDetailsTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/test/java/org/apache/qpid/test/unit/client/BrokerDetails/BrokerDetailsTest.java?rev=1684078&r1=1684077&r2=1684078&view=diff
==============================================================================
--- qpid/java/trunk/client/src/test/java/org/apache/qpid/test/unit/client/BrokerDetails/BrokerDetailsTest.java (original)
+++ qpid/java/trunk/client/src/test/java/org/apache/qpid/test/unit/client/BrokerDetails/BrokerDetailsTest.java Sun Jun  7 21:02:02 2015
@@ -20,9 +20,8 @@
  */
 package org.apache.qpid.test.unit.client.BrokerDetails;
 
-import org.apache.qpid.client.AMQBrokerDetails;
+import org.apache.qpid.client.BrokerDetails;
 import org.apache.qpid.configuration.ClientProperties;
-import org.apache.qpid.jms.BrokerDetails;
 import org.apache.qpid.test.utils.QpidTestCase;
 import org.apache.qpid.transport.ConnectionSettings;
 import org.apache.qpid.url.URLSyntaxException;
@@ -32,7 +31,7 @@ public class BrokerDetailsTest extends Q
     public void testDefaultTCP_NODELAY() throws URLSyntaxException
     {
         String brokerURL = "tcp://localhost:5672";
-        AMQBrokerDetails broker = new AMQBrokerDetails(brokerURL);
+        BrokerDetails broker = new BrokerDetails(brokerURL);
 
         assertNull("default value should be null", broker.getProperty(BrokerDetails.OPTIONS_TCP_NO_DELAY));
     }
@@ -40,12 +39,12 @@ public class BrokerDetailsTest extends Q
     public void testOverridingTCP_NODELAY() throws URLSyntaxException
     {
         String brokerURL = "tcp://localhost:5672?tcp_nodelay='true'";
-        AMQBrokerDetails broker = new AMQBrokerDetails(brokerURL);
+        BrokerDetails broker = new BrokerDetails(brokerURL);
 
         assertTrue("value should be true", Boolean.valueOf(broker.getProperty(BrokerDetails.OPTIONS_TCP_NO_DELAY)));
 
         brokerURL = "tcp://localhost:5672?tcp_nodelay='false''&maxprefetch='1'";
-        broker = new AMQBrokerDetails(brokerURL);
+        broker = new BrokerDetails(brokerURL);
 
         assertFalse("value should be false", Boolean.valueOf(broker.getProperty(BrokerDetails.OPTIONS_TCP_NO_DELAY)));
     }
@@ -53,11 +52,12 @@ public class BrokerDetailsTest extends Q
     public void testDefaultConnectTimeout() throws URLSyntaxException
     {
         String brokerURL = "tcp://localhost:5672";
-        AMQBrokerDetails broker = new AMQBrokerDetails(brokerURL);
+        BrokerDetails broker = new BrokerDetails(brokerURL);
 
         ConnectionSettings settings = broker.buildConnectionSettings();
 
-        assertEquals("unexpected default connect timeout value", BrokerDetails.DEFAULT_CONNECT_TIMEOUT, settings.getConnectTimeout());
+        assertEquals("unexpected default connect timeout value",
+                     BrokerDetails.DEFAULT_CONNECT_TIMEOUT, settings.getConnectTimeout());
     }
 
     public void testOverridingConnectTimeout() throws URLSyntaxException
@@ -66,7 +66,7 @@ public class BrokerDetailsTest extends Q
         assertTrue(timeout != BrokerDetails.DEFAULT_CONNECT_TIMEOUT);
 
         String brokerURL = "tcp://localhost:5672?" + BrokerDetails.OPTIONS_CONNECT_TIMEOUT + "='" + timeout + "'";
-        AMQBrokerDetails broker = new AMQBrokerDetails(brokerURL);
+        BrokerDetails broker = new BrokerDetails(brokerURL);
 
         ConnectionSettings settings = broker.buildConnectionSettings();
 
@@ -77,7 +77,7 @@ public class BrokerDetailsTest extends Q
     {
         String url = "tcp://localhost:5672?timeout='200',immediatedelivery='true'";
 
-        AMQBrokerDetails broker = new AMQBrokerDetails(url);
+        BrokerDetails broker = new BrokerDetails(url);
 
         assertTrue(broker.getProperty("timeout").equals("200"));
         assertTrue(broker.getProperty("immediatedelivery").equals("true"));
@@ -87,7 +87,7 @@ public class BrokerDetailsTest extends Q
     {
         String url = "localhost:5672";
 
-        AMQBrokerDetails broker = new AMQBrokerDetails(url);
+        BrokerDetails broker = new BrokerDetails(url);
         assertTrue(broker.getTransport().equals("tcp"));
     }
 
@@ -95,18 +95,18 @@ public class BrokerDetailsTest extends Q
     {
         String url = "tcp://localhost";
 
-        AMQBrokerDetails broker = new AMQBrokerDetails(url);
-        assertTrue(broker.getPort() == AMQBrokerDetails.DEFAULT_PORT);
+        BrokerDetails broker = new BrokerDetails(url);
+        assertTrue(broker.getPort() == BrokerDetails.DEFAULT_PORT);
     }
 
     public void testBothDefaults() throws URLSyntaxException
     {
         String url = "localhost";
 
-        AMQBrokerDetails broker = new AMQBrokerDetails(url);
+        BrokerDetails broker = new BrokerDetails(url);
 
         assertTrue(broker.getTransport().equals("tcp"));
-        assertTrue(broker.getPort() == AMQBrokerDetails.DEFAULT_PORT);
+        assertTrue(broker.getPort() == BrokerDetails.DEFAULT_PORT);
     }
 
     public void testWrongOptionSeparatorInBroker()
@@ -114,7 +114,7 @@ public class BrokerDetailsTest extends Q
         String url = "tcp://localhost:5672+option='value'";
         try
         {
-            new AMQBrokerDetails(url);
+            new BrokerDetails(url);
         }
         catch (URLSyntaxException urise)
         {
@@ -125,7 +125,7 @@ public class BrokerDetailsTest extends Q
     public void testToStringMasksKeyStorePassword() throws Exception
     {
         String url = "tcp://localhost:5672?key_store_password='password'";
-        BrokerDetails details = new AMQBrokerDetails(url);
+        BrokerDetails details = new BrokerDetails(url);
 
         String expectedToString = "tcp://localhost:5672?key_store_password='********'";
         String actualToString = details.toString();
@@ -136,7 +136,7 @@ public class BrokerDetailsTest extends Q
     public void testToStringMasksTrustStorePassword() throws Exception
     {
         String url = "tcp://localhost:5672?trust_store_password='password'";
-        BrokerDetails details = new AMQBrokerDetails(url);
+        BrokerDetails details = new BrokerDetails(url);
 
         String expectedToString = "tcp://localhost:5672?trust_store_password='********'";
         String actualToString = details.toString();
@@ -147,7 +147,7 @@ public class BrokerDetailsTest extends Q
     public void testDefaultSsl() throws URLSyntaxException
     {
         String brokerURL = "tcp://localhost:5672";
-        AMQBrokerDetails broker = new AMQBrokerDetails(brokerURL);
+        BrokerDetails broker = new BrokerDetails(brokerURL);
 
         assertNull("default value should be null", broker.getProperty(BrokerDetails.OPTIONS_SSL));
     }
@@ -155,12 +155,12 @@ public class BrokerDetailsTest extends Q
     public void testOverridingSsl() throws URLSyntaxException
     {
         String brokerURL = "tcp://localhost:5672?ssl='true'";
-        AMQBrokerDetails broker = new AMQBrokerDetails(brokerURL);
+        BrokerDetails broker = new BrokerDetails(brokerURL);
 
         assertTrue("value should be true", Boolean.valueOf(broker.getProperty(BrokerDetails.OPTIONS_SSL)));
 
         brokerURL = "tcp://localhost:5672?ssl='false''&maxprefetch='1'";
-        broker = new AMQBrokerDetails(brokerURL);
+        broker = new BrokerDetails(brokerURL);
 
         assertFalse("value should be false", Boolean.valueOf(broker.getProperty(BrokerDetails.OPTIONS_SSL)));
     }
@@ -168,14 +168,15 @@ public class BrokerDetailsTest extends Q
     public void testHeartbeatDefaultsToNull() throws Exception
     {
         String brokerURL = "tcp://localhost:5672";
-        AMQBrokerDetails broker = new AMQBrokerDetails(brokerURL);
-        assertNull("unexpected default value for " + BrokerDetails.OPTIONS_HEARTBEAT, broker.getProperty(BrokerDetails.OPTIONS_HEARTBEAT));
+        BrokerDetails broker = new BrokerDetails(brokerURL);
+        assertNull("unexpected default value for " + BrokerDetails.OPTIONS_HEARTBEAT, broker.getProperty(
+                BrokerDetails.OPTIONS_HEARTBEAT));
     }
 
     public void testOverriddingHeartbeat() throws Exception
     {
         String brokerURL = "tcp://localhost:5672?heartbeat='60'";
-        AMQBrokerDetails broker = new AMQBrokerDetails(brokerURL);
+        BrokerDetails broker = new BrokerDetails(brokerURL);
         assertEquals(60, Integer.parseInt(broker.getProperty(BrokerDetails.OPTIONS_HEARTBEAT)));
 
         assertEquals(Integer.valueOf(60), broker.buildConnectionSettings().getHeartbeatInterval08());
@@ -185,7 +186,7 @@ public class BrokerDetailsTest extends Q
 	public void testLegacyHeartbeat() throws Exception
     {
         String brokerURL = "tcp://localhost:5672?idle_timeout='60000'";
-        AMQBrokerDetails broker = new AMQBrokerDetails(brokerURL);
+        BrokerDetails broker = new BrokerDetails(brokerURL);
         assertEquals(60000, Integer.parseInt(broker.getProperty(BrokerDetails.OPTIONS_IDLE_TIMEOUT)));
 
         assertEquals(Integer.valueOf(60), broker.buildConnectionSettings().getHeartbeatInterval08());
@@ -194,7 +195,7 @@ public class BrokerDetailsTest extends Q
     public void testSslVerifyHostNameIsTurnedOnByDefault() throws Exception
     {
         String brokerURL = "tcp://localhost:5672?ssl='true'";
-        AMQBrokerDetails broker = new AMQBrokerDetails(brokerURL);
+        BrokerDetails broker = new BrokerDetails(brokerURL);
         ConnectionSettings connectionSettings = broker.buildConnectionSettings();
         assertTrue(String.format("Unexpected '%s' option value", BrokerDetails.OPTIONS_SSL_VERIFY_HOSTNAME),
                 connectionSettings.isVerifyHostname());
@@ -205,7 +206,7 @@ public class BrokerDetailsTest extends Q
     public void testSslVerifyHostNameIsTurnedOff() throws Exception
     {
         String brokerURL = "tcp://localhost:5672?ssl='true'&ssl_verify_hostname='false'";
-        AMQBrokerDetails broker = new AMQBrokerDetails(brokerURL);
+        BrokerDetails broker = new BrokerDetails(brokerURL);
         ConnectionSettings connectionSettings = broker.buildConnectionSettings();
         assertFalse(String.format("Unexpected '%s' option value", BrokerDetails.OPTIONS_SSL_VERIFY_HOSTNAME),
                 connectionSettings.isVerifyHostname());
@@ -217,7 +218,7 @@ public class BrokerDetailsTest extends Q
     {
         setTestSystemProperty(ClientProperties.CONNECTION_OPTION_SSL_VERIFY_HOST_NAME, "false");
         String brokerURL = "tcp://localhost:5672?ssl='true'";
-        AMQBrokerDetails broker = new AMQBrokerDetails(brokerURL);
+        BrokerDetails broker = new BrokerDetails(brokerURL);
         ConnectionSettings connectionSettings = broker.buildConnectionSettings();
         assertFalse(String.format("Unexpected '%s' option value", BrokerDetails.OPTIONS_SSL_VERIFY_HOSTNAME),
                 connectionSettings.isVerifyHostname());

Modified: qpid/java/trunk/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java?rev=1684078&r1=1684077&r2=1684078&view=diff
==============================================================================
--- qpid/java/trunk/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java (original)
+++ qpid/java/trunk/client/src/test/java/org/apache/qpid/test/unit/client/connectionurl/ConnectionURLTest.java Sun Jun  7 21:02:02 2015
@@ -28,9 +28,8 @@ import java.io.Serializable;
 
 import junit.framework.TestCase;
 
-import org.apache.qpid.client.AMQBrokerDetails;
+import org.apache.qpid.client.BrokerDetails;
 import org.apache.qpid.client.AMQConnectionURL;
-import org.apache.qpid.jms.BrokerDetails;
 import org.apache.qpid.jms.ConnectionURL;
 import org.apache.qpid.url.URLSyntaxException;
 
@@ -428,7 +427,7 @@ public class ConnectionURLTest extends T
         AMQConnectionURL connection = new AMQConnectionURL(url);
 
         BrokerDetails broker = connection.getBrokerDetails(0);
-        assertTrue(broker.getPort() == AMQBrokerDetails.DEFAULT_PORT);
+        assertTrue(broker.getPort() == BrokerDetails.DEFAULT_PORT);
 
     }
 

Modified: qpid/java/trunk/client/src/test/java/org/apache/qpid/test/unit/message/TestAMQSession.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/client/src/test/java/org/apache/qpid/test/unit/message/TestAMQSession.java?rev=1684078&r1=1684077&r2=1684078&view=diff
==============================================================================
--- qpid/java/trunk/client/src/test/java/org/apache/qpid/test/unit/message/TestAMQSession.java (original)
+++ qpid/java/trunk/client/src/test/java/org/apache/qpid/test/unit/message/TestAMQSession.java Sun Jun  7 21:02:02 2015
@@ -44,7 +44,7 @@ public class TestAMQSession extends AMQS
 
     public TestAMQSession(AMQConnection connection)
     {
-        super(connection, 0, false, AUTO_ACKNOWLEDGE, null, 0, 0);
+        super(connection, 0, false, AUTO_ACKNOWLEDGE, 0, 0);
     }
 
     public void acknowledgeMessage(long deliveryTag, boolean multiple)

Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java?rev=1684078&r1=1684077&r2=1684078&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java Sun Jun  7 21:02:02 2015
@@ -318,6 +318,143 @@ public class BasicContentHeaderPropertie
         }
     }
 
+    public int read(DataInput input) throws IOException
+    {
+
+        _propertyFlags = input.readUnsignedShort();
+        int length = 2;
+        if ((_propertyFlags & (CONTENT_TYPE_MASK)) != 0)
+        {
+            length++;
+            _contentType = EncodingUtils.readAMQShortString(input);
+            if(_contentType != null)
+            {
+                length += _contentType.length();
+            }
+        }
+
+        if ((_propertyFlags & ENCODING_MASK) != 0)
+        {
+            length++;
+            _encoding = EncodingUtils.readAMQShortString(input);
+            if(_encodedForm != null)
+            {
+                length += _encoding.length();
+            }
+        }
+
+        if ((_propertyFlags & HEADERS_MASK) != 0)
+        {
+            int fieldTableLength = input.readInt();
+
+            _headers = new FieldTable(input, fieldTableLength);
+
+            length += 4;
+            length += fieldTableLength;
+        }
+
+        if ((_propertyFlags & DELIVERY_MODE_MASK) != 0)
+        {
+            _deliveryMode = input.readByte();
+            length++;
+        }
+
+        if ((_propertyFlags & PRIORITY_MASK) != 0)
+        {
+            _priority = input.readByte();
+            length++;
+        }
+
+        if ((_propertyFlags & CORRELATION_ID_MASK) != 0)
+        {
+            length++;
+            _correlationId = EncodingUtils.readAMQShortString(input);
+            if(_correlationId != null)
+            {
+                length += _correlationId.length();
+            }
+        }
+
+        if ((_propertyFlags & REPLY_TO_MASK) != 0)
+        {
+            length++;
+            _replyTo = EncodingUtils.readAMQShortString(input);
+            if(_replyTo != null)
+            {
+                length += _replyTo.length();
+            }
+        }
+
+        if ((_propertyFlags & EXPIRATION_MASK) != 0)
+        {
+            length++;
+            AMQShortString expiration = EncodingUtils.readAMQShortString(input);
+            if(expiration != null)
+            {
+                length += expiration.length();
+                _expiration = Long.parseLong(expiration.toString());
+            }
+        }
+
+        if ((_propertyFlags & MESSAGE_ID_MASK) != 0)
+        {
+            length++;
+            _messageId = EncodingUtils.readAMQShortString(input);
+            if(_messageId != null)
+            {
+                length += _messageId.length();
+            }
+        }
+
+        if ((_propertyFlags & TIMESTAMP_MASK) != 0)
+        {
+            _timestamp = input.readLong();
+            length += 8;
+        }
+
+        if ((_propertyFlags & TYPE_MASK) != 0)
+        {
+            length++;
+            _type = EncodingUtils.readAMQShortString(input);
+            if(_type != null)
+            {
+                length += _type.length();
+            }
+        }
+
+        if ((_propertyFlags & USER_ID_MASK) != 0)
+        {
+            length++;
+            _userId = EncodingUtils.readAMQShortString(input);
+            if(_userId != null)
+            {
+                length += _userId.length();
+            }
+        }
+
+        if ((_propertyFlags & APPLICATION_ID_MASK) != 0)
+        {
+            length++;
+            _appId = EncodingUtils.readAMQShortString(input);
+            if(_appId != null)
+            {
+                length += _appId.length();
+            }
+        }
+
+        if ((_propertyFlags & CLUSTER_ID_MASK) != 0)
+        {
+            length++;
+            _clusterId = EncodingUtils.readAMQShortString(input);
+            if(_clusterId != null)
+            {
+                length += _clusterId.length();
+            }
+        }
+
+        return length;
+    }
+
 
     public long writePropertyListPayload(final ByteBufferSender sender) throws IOException
     {



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org