servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r407213 [2/2] - in /incubator/servicemix/trunk/servicemix-core/src: main/java/org/apache/servicemix/jbi/container/ main/java/org/apache/servicemix/jbi/nmr/ main/java/org/apache/servicemix/jbi/nmr/flow/ main/java/org/apache/servicemix/jbi/nm...
Date Wed, 17 May 2006 10:27:33 GMT
Modified: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/nmr/SubscriptionPropertyCopyTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/nmr/SubscriptionPropertyCopyTest.java?rev=407213&r1=407212&r2=407213&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/nmr/SubscriptionPropertyCopyTest.java
(original)
+++ incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/nmr/SubscriptionPropertyCopyTest.java
Wed May 17 03:27:31 2006
@@ -60,13 +60,13 @@
 		JBIContainer container = new JBIContainer();
 		try {
             if (subscriptionFlowName != null && !subscriptionFlowName.equals(flowName))
{
-                container.getBroker().setFlows(new Flow[] { FlowProvider.getFlow(flowName),
-                                                            FlowProvider.getFlow(subscriptionFlowName)});
+                container.getDefaultBroker().setFlows(new Flow[] { FlowProvider.getFlow(flowName),
+                                                                   FlowProvider.getFlow(subscriptionFlowName)});
             } else {
-                container.getBroker().setFlows(new Flow[] { FlowProvider.getFlow(flowName)
});
+                container.getDefaultBroker().setFlows(new Flow[] { FlowProvider.getFlow(flowName)
});
             }
             if (subscriptionFlowName != null) {
-                container.getBroker().getSubscriptionManager().setFlowName(subscriptionFlowName);
+                container.getDefaultBroker().getSubscriptionManager().setFlowName(subscriptionFlowName);
             }
             // TODO: check why the following line is enabled, there is 
             // a 5 seconds pause when Management stuff is initialized

Modified: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/nmr/SubscriptionTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/nmr/SubscriptionTest.java?rev=407213&r1=407212&r2=407213&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/nmr/SubscriptionTest.java
(original)
+++ incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/nmr/SubscriptionTest.java
Wed May 17 03:27:31 2006
@@ -89,13 +89,13 @@
 		try {
             container.setEmbedded(true);
             if (subscriptionFlowName != null && !subscriptionFlowName.equals(flowName))
{
-                container.getBroker().setFlows(new Flow[] { FlowProvider.getFlow(flowName),
+                container.getDefaultBroker().setFlows(new Flow[] { FlowProvider.getFlow(flowName),
                                                             FlowProvider.getFlow(subscriptionFlowName)});
             } else {
-                container.getBroker().setFlows(new Flow[] { FlowProvider.getFlow(flowName)
});
+                container.getDefaultBroker().setFlows(new Flow[] { FlowProvider.getFlow(flowName)
});
             }
 			if (subscriptionFlowName != null) {
-				container.getBroker().getSubscriptionManager().setFlowName(subscriptionFlowName);
+				container.getDefaultBroker().getSubscriptionManager().setFlowName(subscriptionFlowName);
 			}
             // TODO: check why the following line is enabled, there is 
             // a 5 seconds pause when Management stuff is initialized

Added: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/GroupPrincipalTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/GroupPrincipalTest.java?rev=407213&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/GroupPrincipalTest.java
(added)
+++ incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/GroupPrincipalTest.java
Wed May 17 03:27:31 2006
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.jbi.security;
+
+import junit.framework.TestCase;
+
+
+/**
+ * @version $Rev: $ $Date: $
+ */
+public class GroupPrincipalTest extends TestCase {
+
+    public void testArguments() {
+        GroupPrincipal principal = new GroupPrincipal("FOO");
+
+       assertEquals("FOO", principal.getName());
+
+        try {
+            new GroupPrincipal(null);
+            fail("Should have thrown IllegalArgumentException");
+        } catch (IllegalArgumentException ingore) {
+
+        }
+    }
+
+    public void testHash() {
+        GroupPrincipal p1 = new GroupPrincipal("FOO");
+        GroupPrincipal p2 = new GroupPrincipal("FOO");
+
+        assertEquals(p1.hashCode(), p1.hashCode());
+        assertEquals(p1.hashCode(), p2.hashCode());
+    }
+
+    public void testEquals() {
+        GroupPrincipal p1 = new GroupPrincipal("FOO");
+        GroupPrincipal p2 = new GroupPrincipal("FOO");
+        GroupPrincipal p3 = new GroupPrincipal("BAR");
+
+        assertTrue(p1.equals(p1));
+        assertTrue(p1.equals(p2));
+        assertFalse(p1.equals(null));
+        assertFalse(p1.equals("FOO"));
+        assertFalse(p1.equals(p3));
+    }
+}

Added: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/PropertiesLoginModuleTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/PropertiesLoginModuleTest.java?rev=407213&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/PropertiesLoginModuleTest.java
(added)
+++ incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/PropertiesLoginModuleTest.java
Wed May 17 03:27:31 2006
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.jbi.security;
+
+import java.io.IOException;
+import java.net.URL;
+
+import javax.security.auth.Subject;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.login.FailedLoginException;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+
+import junit.framework.TestCase;
+
+
+/**
+ * @version $Rev: $ $Date: $
+ */
+public class PropertiesLoginModuleTest extends TestCase {
+    
+    static {
+        String path = System.getProperty("java.security.auth.login.config");
+        if (path == null) {
+            URL resource = PropertiesLoginModuleTest.class.getResource("login.config");
+            if (resource != null) {
+                path = resource.getFile();
+                System.setProperty("java.security.auth.login.config", path);
+            }
+        }
+        System.out.println("Path to login config: " + path);
+    }
+
+    public void testLogin() throws LoginException {
+        LoginContext context = new LoginContext("servicemix-domain", new CallbackHandler()
{
+            public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
+                for (int i = 0; i < callbacks.length; i++) {
+                    if (callbacks[i] instanceof NameCallback) {
+                        ((NameCallback) callbacks[i]).setName("first");
+                    } else if (callbacks[i] instanceof PasswordCallback) {
+                        ((PasswordCallback) callbacks[i]).setPassword("secret".toCharArray());
+                    } else {
+                        throw new UnsupportedCallbackException(callbacks[i]);
+                    }
+                }
+            }
+        });
+        context.login();
+
+        Subject subject = context.getSubject();
+
+        assertEquals("Should have three principals", 3, subject.getPrincipals().size());
+        assertEquals("Should have one user principal", 1, subject.getPrincipals(UserPrincipal.class).size());
+        assertEquals("Should have two group principals", 2, subject.getPrincipals(GroupPrincipal.class).size());
+
+        context.logout();
+
+        assertEquals("Should have zero principals", 0, subject.getPrincipals().size());
+    }
+
+    public void testBadUseridLogin() throws Exception {
+        LoginContext context = new LoginContext("servicemix-domain", new CallbackHandler()
{
+            public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
+                for (int i = 0; i < callbacks.length; i++) {
+                    if (callbacks[i] instanceof NameCallback) {
+                        ((NameCallback) callbacks[i]).setName("BAD");
+                    } else if (callbacks[i] instanceof PasswordCallback) {
+                        ((PasswordCallback) callbacks[i]).setPassword("secret".toCharArray());
+                    } else {
+                        throw new UnsupportedCallbackException(callbacks[i]);
+                    }
+                }
+            }
+        });
+        try {
+            context.login();
+            fail("Should have thrown a FailedLoginException");
+        } catch (FailedLoginException doNothing) {
+        }
+
+    }
+
+    public void testBadPWLogin() throws Exception {
+        LoginContext context = new LoginContext("servicemix-domain", new CallbackHandler()
{
+            public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
+                for (int i = 0; i < callbacks.length; i++) {
+                    if (callbacks[i] instanceof NameCallback) {
+                        ((NameCallback) callbacks[i]).setName("first");
+                    } else if (callbacks[i] instanceof PasswordCallback) {
+                        ((PasswordCallback) callbacks[i]).setPassword("BAD".toCharArray());
+                    } else {
+                        throw new UnsupportedCallbackException(callbacks[i]);
+                    }
+                }
+            }
+        });
+        try {
+            context.login();
+            fail("Should have thrown a FailedLoginException");
+        } catch (FailedLoginException doNothing) {
+        }
+
+    }
+}

Added: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/SecuredBrokerTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/SecuredBrokerTest.java?rev=407213&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/SecuredBrokerTest.java
(added)
+++ incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/SecuredBrokerTest.java
Wed May 17 03:27:31 2006
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.jbi.security;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.jbi.messaging.InOnly;
+import javax.security.auth.Subject;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.login.LoginContext;
+
+import junit.framework.TestCase;
+
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.client.ServiceMixClient;
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.tck.ReceiverComponent;
+
+public class SecuredBrokerTest extends TestCase {
+
+    static {
+        String path = System.getProperty("java.security.auth.login.config");
+        if (path == null) {
+            URL resource = PropertiesLoginModuleTest.class.getResource("login.config");
+            if (resource != null) {
+                path = resource.getFile();
+                System.setProperty("java.security.auth.login.config", path);
+            }
+        }
+        System.out.println("Path to login config: " + path);
+    }
+
+    protected JBIContainer jbi;
+    protected ReceiverComponent receiver;
+    
+    protected void setUp() throws Exception {
+        jbi = new JBIContainer();
+        jbi.setUseMBeanServer(false);
+        jbi.setEmbedded(true);
+        List entries = new ArrayList();
+        entries.add(new AuthorizationEntry(ReceiverComponent.SERVICE, null, "programmers"));
+        AuthorizationMap map = new DefaultAuthorizationMap(entries);
+        SecuredBroker broker = new SecuredBroker(map);
+        jbi.setBroker(broker);
+        jbi.init();
+        
+        receiver = new ReceiverComponent();
+        jbi.activateComponent(receiver, "receiver");
+
+        jbi.start();
+    }
+    
+    protected void tearDown() throws Exception {
+        jbi.shutDown();
+    }
+    
+    protected Subject login(final String username, final String password) throws Exception
{
+        LoginContext context = new LoginContext("servicemix-domain", new CallbackHandler()
{
+            public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
+                for (int i = 0; i < callbacks.length; i++) {
+                    if (callbacks[i] instanceof NameCallback) {
+                        ((NameCallback) callbacks[i]).setName(username);
+                    } else if (callbacks[i] instanceof PasswordCallback) {
+                        ((PasswordCallback) callbacks[i]).setPassword(password.toCharArray());
+                    } else {
+                        throw new UnsupportedCallbackException(callbacks[i]);
+                    }
+                }
+            }
+        });
+        context.login();
+        return context.getSubject();
+    }
+    
+    public void testOk() throws Exception {
+        Subject subject = login("first", "secret");
+        ServiceMixClient client = new DefaultServiceMixClient(jbi);
+        InOnly me = client.createInOnlyExchange();
+        me.setService(ReceiverComponent.SERVICE);
+        me.getInMessage().setSecuritySubject(subject);
+        me.getInMessage().setContent(new StringSource("<hello>world</hello>"));
+        client.sendSync(me);
+        
+        receiver.getMessageList().assertMessagesReceived(1);
+    }
+    
+    public void testNOk() throws Exception {
+        Subject subject = login("second", "password");
+        ServiceMixClient client = new DefaultServiceMixClient(jbi);
+        InOnly me = client.createInOnlyExchange();
+        me.setService(ReceiverComponent.SERVICE);
+        me.getInMessage().setSecuritySubject(subject);
+        me.getInMessage().setContent(new StringSource("<hello>world</hello>"));
+        try {
+            client.sendSync(me);
+            fail("Should have thrown a SecurityException");
+        } catch (SecurityException e) {
+            // ok
+        }
+    }
+    
+}

Added: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/SpringSecuredBrokerTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/SpringSecuredBrokerTest.java?rev=407213&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/SpringSecuredBrokerTest.java
(added)
+++ incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/SpringSecuredBrokerTest.java
Wed May 17 03:27:31 2006
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.jbi.security;
+
+import java.io.IOException;
+import java.net.URL;
+
+import javax.jbi.messaging.InOnly;
+import javax.security.auth.Subject;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.login.LoginContext;
+import javax.xml.namespace.QName;
+
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.client.ServiceMixClient;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.tck.Receiver;
+import org.apache.servicemix.tck.ReceiverComponent;
+import org.apache.servicemix.tck.SpringTestSupport;
+import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+
+public class SpringSecuredBrokerTest extends SpringTestSupport {
+
+    static {
+        String path = System.getProperty("java.security.auth.login.config");
+        if (path == null) {
+            URL resource = PropertiesLoginModuleTest.class.getResource("login.config");
+            if (resource != null) {
+                path = resource.getFile();
+                System.setProperty("java.security.auth.login.config", path);
+            }
+        }
+        System.out.println("Path to login config: " + path);
+    }
+
+    protected Receiver receiver1;
+    protected Receiver receiver2;
+    protected Receiver receiver3;
+    protected ServiceMixClient client;
+    
+    protected void setUp() throws Exception {
+        super.setUp();
+        receiver1 = (Receiver) jbi.getBean("receiver1");
+        receiver2 = (Receiver) jbi.getBean("receiver2");
+        receiver3 = (Receiver) jbi.getBean("receiver3");
+        client = new DefaultServiceMixClient(jbi);
+    }
+    
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    protected AbstractXmlApplicationContext createBeanFactory() {
+        return new ClassPathXmlApplicationContext("org/apache/servicemix/jbi/security/secure.xml");
+    }
+    
+    protected Subject login(final String username, final String password) throws Exception
{
+        LoginContext context = new LoginContext("servicemix-domain", new CallbackHandler()
{
+            public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
+                for (int i = 0; i < callbacks.length; i++) {
+                    if (callbacks[i] instanceof NameCallback) {
+                        ((NameCallback) callbacks[i]).setName(username);
+                    } else if (callbacks[i] instanceof PasswordCallback) {
+                        ((PasswordCallback) callbacks[i]).setPassword(password.toCharArray());
+                    } else {
+                        throw new UnsupportedCallbackException(callbacks[i]);
+                    }
+                }
+            }
+        });
+        context.login();
+        return context.getSubject();
+    }
+    
+    protected void send(String username, String password, QName service) throws Exception
{
+        Subject subject = login(username, password);
+        InOnly me = client.createInOnlyExchange();
+        me.setService(service);
+        me.getInMessage().setSecuritySubject(subject);
+        me.getInMessage().setContent(new StringSource("<hello>world</hello>"));
+        client.sendSync(me);
+    }
+    
+    public void testAuthorizationsOnReceiver1() throws Exception {
+        QName service = new QName("http://servicemix.org/example/1", "receiver1");
+        // receiver1 should be available to: programmers, accounting, testers
+        send("first", "secret", service);
+        send("second", "password", service);
+        send("third", "another", service);
+    }
+    
+    public void testAuthorizationsOnReceiver2() throws Exception {
+        QName service = new QName("http://servicemix.org/example/1", "receiver2");
+        // receiver2 should be available to: programmers, accounting
+        send("first", "secret", service);
+        send("second", "password", service);
+        try {
+            send("third", "another", service);
+            fail("receiver2 is not available to testers");
+        } catch (SecurityException e) {
+        }
+    }
+    
+    public void testAuthorizationsOnReceiver3() throws Exception {
+        QName service = new QName("http://servicemix.org/example/2", "receiver1");
+        // receiver2 should be available to: programmers
+        send("first", "secret", service);
+        try {
+            send("second", "password", service);
+            fail("receiver2 is not available to accounting");
+        } catch (SecurityException e) {
+        }
+        try {
+            send("third", "another", service);
+            fail("receiver2 is not available to testers");
+        } catch (SecurityException e) {
+        }
+    }
+    
+}

Added: incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/UserPrincipalTest.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/UserPrincipalTest.java?rev=407213&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/UserPrincipalTest.java
(added)
+++ incubator/servicemix/trunk/servicemix-core/src/test/java/org/apache/servicemix/jbi/security/UserPrincipalTest.java
Wed May 17 03:27:31 2006
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.servicemix.jbi.security;
+
+import junit.framework.TestCase;
+
+
+/**
+ * @version $Rev: $ $Date: $
+ */
+public class UserPrincipalTest extends TestCase {
+
+    public void testArguments() {
+        UserPrincipal principal = new UserPrincipal("FOO");
+
+       assertEquals("FOO", principal.getName());
+
+        try {
+            new UserPrincipal(null);
+            fail("Should have thrown IllegalArgumentException");
+        } catch (IllegalArgumentException ingore) {
+
+        }
+    }
+
+    public void testHash() {
+        UserPrincipal p1 = new UserPrincipal("FOO");
+        UserPrincipal p2 = new UserPrincipal("FOO");
+
+        assertEquals(p1.hashCode(), p1.hashCode());
+        assertEquals(p1.hashCode(), p2.hashCode());
+    }
+
+    public void testEquals() {
+        UserPrincipal p1 = new UserPrincipal("FOO");
+        UserPrincipal p2 = new UserPrincipal("FOO");
+        UserPrincipal p3 = new UserPrincipal("BAR");
+
+        assertTrue(p1.equals(p1));
+        assertTrue(p1.equals(p2));
+        assertFalse(p1.equals(null));
+        assertFalse(p1.equals("FOO"));
+        assertFalse(p1.equals(p3));
+    }
+}

Added: incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/security/groups.properties
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/security/groups.properties?rev=407213&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/security/groups.properties
(added)
+++ incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/security/groups.properties
Wed May 17 03:27:31 2006
@@ -0,0 +1,4 @@
+programmers=first
+accounting=second
+employees=first,second
+testers=third
\ No newline at end of file

Added: incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/security/login.config
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/security/login.config?rev=407213&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/security/login.config
(added)
+++ incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/security/login.config
Wed May 17 03:27:31 2006
@@ -0,0 +1,6 @@
+servicemix-domain {
+    org.apache.servicemix.jbi.security.PropertiesLoginModule required
+        debug=true
+        org.apache.servicemix.security.properties.user="users.properties"
+        org.apache.servicemix.security.properties.group="groups.properties";
+};
\ No newline at end of file

Added: incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/security/secure.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/security/secure.xml?rev=407213&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/security/secure.xml
(added)
+++ incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/security/secure.xml
Wed May 17 03:27:31 2006
@@ -0,0 +1,39 @@
+<beans xmlns:sm="http://servicemix.apache.org/config/1.0"
+       xmlns:ex1="http://servicemix.org/example/1"
+       xmlns:ex2="http://servicemix.org/example/2">
+
+  <sm:container id="jbi" embedded="true" useMBeanServer="false">
+    <sm:broker>
+      <sm:securedBroker>
+        <sm:authorizationMap>
+	      <sm:authorizationMap>
+	        <sm:authorizationEntries>
+	          <sm:authorizationEntry service="*:*" roles="programmers" />
+	          <sm:authorizationEntry service="ex1:*" roles="accounting" />
+	          <sm:authorizationEntry service="ex1:receiver1" roles="testers" />
+	        </sm:authorizationEntries>
+	      </sm:authorizationMap>
+        </sm:authorizationMap>
+      </sm:securedBroker>
+    </sm:broker>
+      
+    <sm:activationSpecs>
+      <sm:activationSpec id="receiver1" service="ex1:receiver1">
+        <sm:component>
+          <bean class="org.apache.servicemix.tck.ReceiverComponent" />
+        </sm:component>
+      </sm:activationSpec>
+      <sm:activationSpec id="receiver2" service="ex1:receiver2">
+        <sm:component>
+          <bean class="org.apache.servicemix.tck.ReceiverComponent" />
+        </sm:component>
+      </sm:activationSpec>
+      <sm:activationSpec id="receiver3" service="ex2:receiver1">
+        <sm:component>
+          <bean class="org.apache.servicemix.tck.ReceiverComponent" />
+        </sm:component>
+      </sm:activationSpec>
+    </sm:activationSpecs>
+  </sm:container>
+
+</beans>
\ No newline at end of file

Added: incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/security/users.properties
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/security/users.properties?rev=407213&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/security/users.properties
(added)
+++ incubator/servicemix/trunk/servicemix-core/src/test/resources/org/apache/servicemix/jbi/security/users.properties
Wed May 17 03:27:31 2006
@@ -0,0 +1,3 @@
+first=secret
+second=password
+third=another
\ No newline at end of file



Mime
View raw message