Package org.hornetq.core.security

Examples of org.hornetq.core.security.Role


   {
      SimpleString queue = RandomUtil.randomSimpleString();
      SimpleString address = RandomUtil.randomSimpleString();

      // guest can not create queue
      Role role = new Role("roleCanNotCreateQueue", true, true, false, true, false, true, true);
      Set<Role> roles = new HashSet<Role>();
      roles.add(role);
      server.getSecurityRepository().addMatch(address.toString(), roles);
      HornetQSecurityManager securityManager = server.getSecurityManager();
      securityManager.addRole("guest", "roleCanNotCreateQueue");
View Full Code Here


      HornetQSecurityManager securityManager = server.getSecurityManager();
      securityManager.addUser("admin", "admin");
      securityManager.addUser("guest", "guest");
      securityManager.setDefaultUser("guest");

      Role role = new Role("notif", true, true, true, true, true, true, true);
      Set<Role> roles = new HashSet<Role>();
      roles.add(role);
      server.getSecurityRepository().addMatch(ConfigurationImpl.DEFAULT_MANAGEMENT_NOTIFICATION_ADDRESS.toString(),
                                              roles);
View Full Code Here

   public void testGetRoles() throws Exception
   {
      SimpleString address = RandomUtil.randomSimpleString();
      SimpleString queue = RandomUtil.randomSimpleString();
      Role role = new Role(RandomUtil.randomString(),
                           RandomUtil.randomBoolean(),
                           RandomUtil.randomBoolean(),
                           RandomUtil.randomBoolean(),
                           RandomUtil.randomBoolean(),
                           RandomUtil.randomBoolean(),
                           RandomUtil.randomBoolean(),
                           RandomUtil.randomBoolean());

      session.createQueue(address, queue, true);

      AddressControl addressControl = createManagementControl(address);
      Object[] roles = addressControl.getRoles();
      Assert.assertEquals(0, roles.length);

      Set<Role> newRoles = new HashSet<Role>();
      newRoles.add(role);
      server.getSecurityRepository().addMatch(address.toString(), newRoles);

      roles = addressControl.getRoles();
      Assert.assertEquals(1, roles.length);
      Object[] r = (Object[])roles[0];
      Assert.assertEquals(role.getName(), r[0]);
      Assert.assertEquals(CheckType.SEND.hasRole(role), r[1]);
      Assert.assertEquals(CheckType.CONSUME.hasRole(role), r[2]);
      Assert.assertEquals(CheckType.CREATE_DURABLE_QUEUE.hasRole(role), r[3]);
      Assert.assertEquals(CheckType.DELETE_DURABLE_QUEUE.hasRole(role), r[4]);
      Assert.assertEquals(CheckType.CREATE_NON_DURABLE_QUEUE.hasRole(role), r[5]);
View Full Code Here

   public void testGetRolesAsJSON() throws Exception
   {
      SimpleString address = RandomUtil.randomSimpleString();
      SimpleString queue = RandomUtil.randomSimpleString();
      Role role = new Role(RandomUtil.randomString(),
                           RandomUtil.randomBoolean(),
                           RandomUtil.randomBoolean(),
                           RandomUtil.randomBoolean(),
                           RandomUtil.randomBoolean(),
                           RandomUtil.randomBoolean(),
                           RandomUtil.randomBoolean(),
                           RandomUtil.randomBoolean());

      session.createQueue(address, queue, true);

      AddressControl addressControl = createManagementControl(address);
      String jsonString = addressControl.getRolesAsJSON();
      Assert.assertNotNull(jsonString);
      RoleInfo[] roles = RoleInfo.from(jsonString);
      Assert.assertEquals(0, roles.length);

      Set<Role> newRoles = new HashSet<Role>();
      newRoles.add(role);
      server.getSecurityRepository().addMatch(address.toString(), newRoles);

      jsonString = addressControl.getRolesAsJSON();
      Assert.assertNotNull(jsonString);
      roles = RoleInfo.from(jsonString);
      Assert.assertEquals(1, roles.length);
      RoleInfo r = roles[0];
      Assert.assertEquals(role.getName(), roles[0].getName());
      Assert.assertEquals(role.isSend(), r.isSend());
      Assert.assertEquals(role.isConsume(), r.isConsume());
      Assert.assertEquals(role.isCreateDurableQueue(), r.isCreateDurableQueue());
      Assert.assertEquals(role.isDeleteDurableQueue(), r.isDeleteDurableQueue());
      Assert.assertEquals(role.isCreateNonDurableQueue(), r.isCreateNonDurableQueue());
      Assert.assertEquals(role.isDeleteNonDurableQueue(), r.isDeleteNonDurableQueue());
      Assert.assertEquals(role.isManage(), r.isManage());

      session.deleteQueue(queue);
   }
View Full Code Here

   public void testSimpleMessageReceivedOnQueueWithSecuritySucceeds() throws Exception
   {
      server.getSecurityManager().addUser("testuser", "testpassword");
      server.getSecurityManager().addRole("testuser", "arole");
      Role role = new Role("arole", false, true, false, false, false, false, false);
         Set<Role> roles = new HashSet<Role>();
         roles.add(role);
       server.getSecurityRepository().addMatch(MDBQUEUEPREFIXED, roles);
      HornetQResourceAdapter qResourceAdapter = new HornetQResourceAdapter();
      MyBootstrapContext ctx = new MyBootstrapContext();
View Full Code Here

                if (config.getType() != ModelType.UNDEFINED) {
                    final Set<Role> roles = new HashSet<Role>();
                    for (final Property role : config.asPropertyList()) {
                        final String name = role.getName();
                        final ModelNode value = role.getValue();
                        roles.add(new Role(name, value.get(SEND_NAME).asBoolean(false),
                                value.get(CONSUME_NAME).asBoolean(false), value.get(CREATEDURABLEQUEUE_NAME).asBoolean(false),
                                value.get(DELETEDURABLEQUEUE_NAME).asBoolean(false), value.get(CREATE_NON_DURABLE_QUEUE_NAME).asBoolean(false),
                                value.get(DELETE_NON_DURABLE_QUEUE_NAME).asBoolean(false), value.get(MANAGE_NAME).asBoolean(false)));
                    }
                    configuration.getSecurityRoles().put(match, roles);
View Full Code Here

      }

      for (String role : allRoles)
      {
         securityRoles.add(new Role(role,
                                    send.contains(role),
                                    consume.contains(role),
                                    createDurableQueue.contains(role),
                                    deleteDurableQueue.contains(role),
                                    createNonDurableQueue.contains(role),
View Full Code Here

      {
         server.start();
         HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
         HornetQSecurityManager securityManager = server.getSecurityManager();
         securityManager.addUser("auser", "pass");
         Role role = new Role("arole", false, false, true, false, false, false, false);
         Set<Role> roles = new HashSet<Role>();
         roles.add(role);
         securityRepository.addMatch(configuration.getManagementAddress().toString(), roles);
         securityManager.addRole("auser", "arole");
         ClientSessionFactory cf = createInVMFactory();
View Full Code Here

         securityManager.addRole("frank", "us-user");
         securityManager.addRole("frank", "news-user");
         securityManager.addRole("frank", "user");
         securityManager.addRole("sam", "news-user");
         securityManager.addRole("sam", "user");
         Role all = new Role("all", true, true, true, true, true, true, true);
         HierarchicalRepository<Set<Role>> repository = server.getSecurityRepository();
         Set<Role> add = new HashSet<Role>();
         add.add(new Role("user", true, true, true, true, true, true, false));
         add.add(all);
         repository.addMatch("#", add);
         Set<Role> add1 = new HashSet<Role>();
         add1.add(all);
         add1.add(new Role("user", false, false, true, true, true, true, false));
         add1.add(new Role("europe-user", true, false, false, false, false, false, false));
         add1.add(new Role("news-user", false, true, false, false, false, false, false));
         repository.addMatch("news.europe.#", add1);
         Set<Role> add2 = new HashSet<Role>();
         add2.add(all);
         add2.add(new Role("user", false, false, true, true, true, true, false));
         add2.add(new Role("us-user", true, false, false, false, false, false, false));
         add2.add(new Role("news-user", false, true, false, false, false, false, false));
         repository.addMatch("news.us.#", add2);
         ClientSession billConnection = null;
         ClientSession andrewConnection = null;
         ClientSession frankConnection = null;
         ClientSession samConnection = null;
View Full Code Here

         securityManager.addRole("frank", "us-user");
         securityManager.addRole("frank", "news-user");
         securityManager.addRole("frank", "user");
         securityManager.addRole("sam", "news-user");
         securityManager.addRole("sam", "user");
         Role all = new Role("all", true, true, true, true, true, true, true);
         HierarchicalRepository<Set<Role>> repository = server.getSecurityRepository();
         Set<Role> add = new HashSet<Role>();
         add.add(new Role("user", true, true, true, true, true, true, false));
         add.add(all);
         repository.addMatch("#", add);
         Set<Role> add1 = new HashSet<Role>();
         add1.add(all);
         add1.add(new Role("user", false, false, true, true, true, true, false));
         add1.add(new Role("europe-user", true, false, false, false, false, false, false));
         add1.add(new Role("news-user", false, true, false, false, false, false, false));
         repository.addMatch("news.europe.#", add1);
         Set<Role> add2 = new HashSet<Role>();
         add2.add(all);
         add2.add(new Role("user", false, false, true, true, true, true, false));
         add2.add(new Role("us-user", true, false, false, false, false, false, false));
         add2.add(new Role("news-user", false, true, false, false, false, false, false));
         repository.addMatch("news.us.#", add2);
         ClientSession billConnection = null;
         ClientSession andrewConnection = null;
         ClientSession frankConnection = null;
         ClientSession samConnection = null;
View Full Code Here

TOP

Related Classes of org.hornetq.core.security.Role

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.