cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jp...@apache.org
Subject cxf git commit: CXF-6120 added a new property to JMSConfiguration to stop creation of the Security Context
Date Fri, 28 Nov 2014 06:35:19 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes 27ce514bb -> 4e332dbfc


CXF-6120 added a new property to JMSConfiguration to stop creation of the Security Context


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/4e332dbf
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/4e332dbf
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/4e332dbf

Branch: refs/heads/2.7.x-fixes
Commit: 4e332dbfc24e00f2304d3c7906c9c95c3f96f04d
Parents: 27ce514
Author: Jason Pell <jpell@apache.org>
Authored: Fri Nov 28 16:50:38 2014 +1100
Committer: Jason Pell <jpell@apache.org>
Committed: Fri Nov 28 16:50:38 2014 +1100

----------------------------------------------------------------------
 .../cxf/transport/jms/JMSConfiguration.java     |   9 +
 .../cxf/transport/jms/JMSDestination.java       |   3 +-
 .../org/apache/cxf/transport/jms/JMSUtils.java  |   9 +-
 .../apache/cxf/transport/jms/JMSUtilsTest.java  |  22 +-
 .../apache/cxf/transport/jms/MessageStub.java   | 302 +++++++++++++++++++
 5 files changed, 340 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/4e332dbf/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
index 892f58f..dcfc329 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSConfiguration.java
@@ -57,6 +57,7 @@ public class JMSConfiguration implements InitializingBean {
     private TaskExecutor taskExecutor;
     private boolean useJms11 = DEFAULT_USEJMS11;
     private boolean reconnectOnException = true;
+    private boolean createSecurityContext = true;
     private boolean messageIdEnabled = true;
     private boolean messageTimestampEnabled = true;
     private boolean pubSubNoLocal;
@@ -116,6 +117,14 @@ public class JMSConfiguration implements InitializingBean {
         }
     }
 
+    public boolean isCreateSecurityContext() {
+        return createSecurityContext;
+    }
+    
+    public void setCreateSecurityContext(boolean b) {
+        this.createSecurityContext = b;
+    }
+    
     public String getCacheLevelName() {
         return cacheLevelName;
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/4e332dbf/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
index a0662f9..1a81687 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
@@ -209,7 +209,8 @@ public class JMSDestination extends AbstractMultiplexDestination
             }
             getLogger().log(Level.FINE, "server received request: ", message);
              // Build CXF message from JMS message
-            Message inMessage = new MessageImpl();            
+            Message inMessage = new MessageImpl();
+            
             JMSUtils.populateIncomingContext(message, inMessage, 
                                              JMSConstants.JMS_SERVER_REQUEST_HEADERS, jmsConfig);
             

http://git-wip-us.apache.org/repos/asf/cxf/blob/4e332dbf/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSUtils.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSUtils.java b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSUtils.java
index 56c0382..7d7b9fe 100644
--- a/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSUtils.java
+++ b/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSUtils.java
@@ -216,9 +216,12 @@ public final class JMSUtils {
             }
             inMessage.put(org.apache.cxf.message.Message.PROTOCOL_HEADERS, protHeaders);
 
-            SecurityContext securityContext = buildSecurityContext(message, jmsConfig);
-            inMessage.put(SecurityContext.class, securityContext);
-
+            // weird construct I know, but the default for this property must be 
+            if (jmsConfig.isCreateSecurityContext()) {
+                SecurityContext securityContext = buildSecurityContext(message, jmsConfig);
+                inMessage.put(SecurityContext.class, securityContext);
+            }
+            
             populateIncomingMessageProperties(message, inMessage, messageProperties);
         } catch (JMSException ex) {
             throw JmsUtils.convertJmsAccessException(ex);

http://git-wip-us.apache.org/repos/asf/cxf/blob/4e332dbf/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSUtilsTest.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSUtilsTest.java
b/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSUtilsTest.java
index 2cdb0d9..c0cf9ab 100644
--- a/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSUtilsTest.java
+++ b/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/JMSUtilsTest.java
@@ -24,11 +24,14 @@ import java.io.UnsupportedEncodingException;
 import java.util.UUID;
 import java.util.concurrent.atomic.AtomicLong;
 
+import javax.jms.Message;
+
+import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.security.SecurityContext;
 import org.junit.Assert;
 import org.junit.Test;
 
 public class JMSUtilsTest extends Assert {
-    
     @Test
     public void testGetEncoding() throws IOException {                
         assertEquals("Get the wrong encoding", JMSUtils.getEncoding("text/xml; charset=utf-8"),
"UTF-8");
@@ -44,6 +47,23 @@ public class JMSUtilsTest extends Assert {
     }
     
     @Test
+    public void testCreateUserSecurityContext() throws Exception {
+        Message service = new MessageStub();
+        JMSConfiguration config = new JMSConfiguration();
+        config.setCreateSecurityContext(true);
+        
+        org.apache.cxf.message.Message inMessage = new MessageImpl();
+        
+        JMSUtils.populateIncomingContext(service, inMessage, "text", config);
+        assertNotNull(inMessage.get(SecurityContext.class));
+        
+        inMessage = new MessageImpl();
+        config.setCreateSecurityContext(false);
+        JMSUtils.populateIncomingContext(service, inMessage, "text", config);
+        assertNull(inMessage.get(SecurityContext.class));
+    }
+    
+    @Test
     public void testCorrelationIDGeneration() {
         final String conduitId = UUID.randomUUID().toString().replaceAll("-", "");
         // test min edge case

http://git-wip-us.apache.org/repos/asf/cxf/blob/4e332dbf/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/MessageStub.java
----------------------------------------------------------------------
diff --git a/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/MessageStub.java
b/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/MessageStub.java
new file mode 100644
index 0000000..bb3e904
--- /dev/null
+++ b/rt/transports/jms/src/test/java/org/apache/cxf/transport/jms/MessageStub.java
@@ -0,0 +1,302 @@
+/**
+ * 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.cxf.transport.jms;
+
+import java.util.Collections;
+import java.util.Enumeration;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+
+public class MessageStub implements Message {
+
+    @Override
+    public String getJMSMessageID() throws JMSException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public void setJMSMessageID(String id) throws JMSException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public long getJMSTimestamp() throws JMSException {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    @Override
+    public void setJMSTimestamp(long timestamp) throws JMSException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public byte[] getJMSCorrelationIDAsBytes() throws JMSException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public void setJMSCorrelationIDAsBytes(byte[] correlationID) throws JMSException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setJMSCorrelationID(String correlationID) throws JMSException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public String getJMSCorrelationID() throws JMSException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Destination getJMSReplyTo() throws JMSException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public void setJMSReplyTo(Destination replyTo) throws JMSException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public Destination getJMSDestination() throws JMSException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public void setJMSDestination(Destination destination) throws JMSException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public int getJMSDeliveryMode() throws JMSException {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    @Override
+    public void setJMSDeliveryMode(int deliveryMode) throws JMSException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public boolean getJMSRedelivered() throws JMSException {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public void setJMSRedelivered(boolean redelivered) throws JMSException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public String getJMSType() throws JMSException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public void setJMSType(String type) throws JMSException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public long getJMSExpiration() throws JMSException {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    @Override
+    public void setJMSExpiration(long expiration) throws JMSException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public int getJMSPriority() throws JMSException {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    @Override
+    public void setJMSPriority(int priority) throws JMSException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void clearProperties() throws JMSException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public boolean propertyExists(String name) throws JMSException {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public boolean getBooleanProperty(String name) throws JMSException {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    @Override
+    public byte getByteProperty(String name) throws JMSException {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    @Override
+    public short getShortProperty(String name) throws JMSException {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    @Override
+    public int getIntProperty(String name) throws JMSException {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    @Override
+    public long getLongProperty(String name) throws JMSException {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    @Override
+    public float getFloatProperty(String name) throws JMSException {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    @Override
+    public double getDoubleProperty(String name) throws JMSException {
+        // TODO Auto-generated method stub
+        return 0;
+    }
+
+    @Override
+    public String getStringProperty(String name) throws JMSException {
+        if ("JMSXUserID".equals(name)) {
+            return "jason";
+        } else {
+            return null;
+        }
+    }
+
+    @Override
+    public Object getObjectProperty(String name) throws JMSException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Enumeration getPropertyNames() throws JMSException {
+        return Collections.emptyEnumeration();
+    }
+
+    @Override
+    public void setBooleanProperty(String name, boolean value) throws JMSException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setByteProperty(String name, byte value) throws JMSException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setShortProperty(String name, short value) throws JMSException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setIntProperty(String name, int value) throws JMSException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setLongProperty(String name, long value) throws JMSException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setFloatProperty(String name, float value) throws JMSException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setDoubleProperty(String name, double value) throws JMSException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setStringProperty(String name, String value) throws JMSException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void setObjectProperty(String name, Object value) throws JMSException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void acknowledge() throws JMSException {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void clearBody() throws JMSException {
+        // TODO Auto-generated method stub
+
+    }
+
+}


Mime
View raw message