Package org.hornetq.core.security

Examples of org.hornetq.core.security.Role


      {
         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 = locator.createSessionFactory();
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 = locator.createSessionFactory();
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

      }

      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

      }

      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

      }

      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

      }

      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

   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

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.