Package org.hornetq.spi.core.security

Examples of org.hornetq.spi.core.security.HornetQSecurityManager


      // 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");

      SecurityNotificationTest.flush(notifConsumer);

      ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY));
      ClientSessionFactory sf = locator.createSessionFactory();
View Full Code Here


      server = HornetQServers.newHornetQServer(conf, false);
      server.start();

      notifQueue = RandomUtil.randomSimpleString();

      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);

      securityManager.addRole("admin", "notif");

      ServerLocator locator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(UnitTestCase.INVM_CONNECTOR_FACTORY));
      ClientSessionFactory sf = locator.createSessionFactory();
      adminSession = sf.createSession("admin", "admin", false, true, true, false, 1);
      adminSession.start();
View Full Code Here

      try
      {
         server.start();
         HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
         HornetQSecurityManager securityManager = server.getSecurityManager();
         securityManager.addUser("auser", "pass");
         securityManager.addUser("guest", "guest");
         securityManager.addRole("guest", "guest");
         securityManager.setDefaultUser("guest");
         Role role = new Role("arole", false, false, false, false, false, false, false);
         Role sendRole = new Role("guest", true, false, true, false, false, false, false);
         Role receiveRole = new Role("receiver", false, true, false, false, false, false, false);
         Set<Role> roles = new HashSet<Role>();
         roles.add(sendRole);
         roles.add(role);
         roles.add(receiveRole);
         securityRepository.addMatch(SecurityTest.addressA, roles);
         securityManager.addRole("auser", "arole");
         ClientSessionFactory cf = locator.createSessionFactory();
         ClientSession senSession = cf.createSession(false, true, true);
         ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
         senSession.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
         ClientProducer cp = senSession.createProducer(SecurityTest.addressA);
         cp.send(session.createMessage(false));
         try
         {
            ClientConsumer cc = session.createConsumer(SecurityTest.queueA);
         }
         catch (HornetQException e)
         {
            Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
         }

         securityManager.addRole("auser", "receiver");

         session.createConsumer(SecurityTest.queueA);

         // Removing the Role... the check should be cached, so the next createConsumer shouldn't fail
         securityManager.removeRole("auser", "receiver");

         session.createConsumer(SecurityTest.queueA);

         session.close();
View Full Code Here

      try
      {
         server.start();
         HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
         HornetQSecurityManager securityManager = server.getSecurityManager();
         securityManager.addUser("auser", "pass");
         securityManager.addUser("guest", "guest");
         securityManager.addRole("guest", "guest");
         securityManager.setDefaultUser("guest");
         Role role = new Role("arole", false, false, false, false, false, false, false);
         Role sendRole = new Role("guest", true, false, true, false, false, false, false);
         Role receiveRole = new Role("receiver", false, true, false, false, false, false, false);
         Set<Role> roles = new HashSet<Role>();
         roles.add(sendRole);
         roles.add(role);
         roles.add(receiveRole);
         securityRepository.addMatch(SecurityTest.addressA, roles);
         securityManager.addRole("auser", "arole");
         ClientSessionFactory cf = locator.createSessionFactory();
         ClientSession senSession = cf.createSession(false, true, true);
         ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
         senSession.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
         ClientProducer cp = senSession.createProducer(SecurityTest.addressA);
         cp.send(session.createMessage(false));
         try
         {
            session.createConsumer(SecurityTest.queueA);
         }
         catch (HornetQException e)
         {
            Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
         }

         securityManager.addRole("auser", "receiver");

         session.createConsumer(SecurityTest.queueA);

         // Removing the Role... the check should be cached... but we used setSecurityInvalidationInterval(0), so the
         // next createConsumer should fail
         securityManager.removeRole("auser", "receiver");

         try
         {
            session.createConsumer(SecurityTest.queueA);
         }
View Full Code Here

      try
      {
         server.start();
         HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
         HornetQSecurityManager securityManager = server.getSecurityManager();
         securityManager.addUser("auser", "pass");
         securityManager.addUser("guest", "guest");
         securityManager.addRole("guest", "guest");
         securityManager.setDefaultUser("guest");
         Role role = new Role("arole", false, false, false, false, false, false, false);
         System.out.println("guest:" + role);
         Role sendRole = new Role("guest", true, false, true, false, false, false, false);
         System.out.println("guest:" + sendRole);
         Role receiveRole = new Role("receiver", false, true, false, false, false, false, false);
         System.out.println("guest:" + receiveRole);
         Set<Role> roles = new HashSet<Role>();
         roles.add(sendRole);
         roles.add(role);
         roles.add(receiveRole);
         securityRepository.addMatch(SecurityTest.addressA, roles);
         securityManager.addRole("auser", "arole");
         ClientSessionFactory cf = locator.createSessionFactory();

         ClientSession senSession = cf.createSession(false, true, true);
         ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
         senSession.createQueue(SecurityTest.addressA, SecurityTest.queueA, true);
         ClientProducer cp = senSession.createProducer(SecurityTest.addressA);
         cp.send(session.createMessage(false));
         try
         {
            session.createConsumer(SecurityTest.queueA);
         }
         catch (HornetQException e)
         {
            Assert.assertEquals(HornetQException.SECURITY_EXCEPTION, e.getCode());
         }

         securityManager.addRole("auser", "receiver");

         ClientConsumer consumer = session.createConsumer(SecurityTest.queueA);

         // Removing the Role... the check should be cached... but we used setSecurityInvalidationInterval(0), so the
         // next createConsumer should fail
         securityManager.removeRole("auser", "guest");

         ClientSession sendingSession = cf.createSession("auser", "pass", false, false, false, false, 0);
         ClientProducer prod = sendingSession.createProducer(SecurityTest.addressA);
         prod.send(createTextMessage(sendingSession, "Test", true));
         prod.send(createTextMessage(sendingSession, "Test", true));
View Full Code Here

      try
      {
         server.start();
         HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
         HornetQSecurityManager securityManager = server.getSecurityManager();
         securityManager.addUser("auser", "pass");
         Role role = new Role("arole", false, false, false, false, false, false, true);
         Set<Role> roles = new HashSet<Role>();
         roles.add(role);
         securityRepository.addMatch(configuration.getManagementAddress().toString(), roles);
         securityManager.addRole("auser", "arole");
         locator.setBlockOnNonDurableSend(true);
         ClientSessionFactory cf = locator.createSessionFactory();
         ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
         ClientProducer cp = session.createProducer(configuration.getManagementAddress());
         cp.send(session.createMessage(false));
View Full Code Here

      try
      {
         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();
         ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
         session.createQueue(configuration.getManagementAddress().toString(), SecurityTest.queueA, true);
         ClientProducer cp = session.createProducer(configuration.getManagementAddress());
         cp.send(session.createMessage(false));
View Full Code Here

      try
      {
         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();
         ClientSession session = cf.createSession("auser", "pass", false, true, true, false, -1);
         session.createQueue(configuration.getManagementAddress().toString(), SecurityTest.queueA, true);
         ClientProducer cp = session.createProducer(configuration.getManagementAddress());
         cp.send(session.createMessage(false));
View Full Code Here

      configuration.setSecurityEnabled(true);
      HornetQServer server = createServer(false, configuration);
      try
      {
         server.start();
         HornetQSecurityManager securityManager = server.getSecurityManager();
         securityManager.addUser("all", "all");
         securityManager.addUser("bill", "hornetq");
         securityManager.addUser("andrew", "hornetq1");
         securityManager.addUser("frank", "hornetq2");
         securityManager.addUser("sam", "hornetq3");
         securityManager.addRole("all", "all");
         securityManager.addRole("bill", "user");
         securityManager.addRole("andrew", "europe-user");
         securityManager.addRole("andrew", "user");
         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);
View Full Code Here

      configuration.setSecurityEnabled(true);
      HornetQServer server = createServer(false, configuration);
      try
      {
         server.start();
         HornetQSecurityManager securityManager = server.getSecurityManager();
         securityManager.addUser("all", "all");
         securityManager.addUser("bill", "hornetq");
         securityManager.addUser("andrew", "hornetq1");
         securityManager.addUser("frank", "hornetq2");
         securityManager.addUser("sam", "hornetq3");
         securityManager.addRole("all", "all");
         securityManager.addRole("bill", "user");
         securityManager.addRole("andrew", "europe-user");
         securityManager.addRole("andrew", "user");
         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);
View Full Code Here

TOP

Related Classes of org.hornetq.spi.core.security.HornetQSecurityManager

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.