Examples of JaasSecurityManagerServiceMBean


Examples of org.jboss.security.plugins.JaasSecurityManagerServiceMBean

   public void testFlushOnSessionInvalidation() throws Exception
   {
      log.info("+++ testFlushOnSessionInvalidation");
      MBeanServerConnection conn = (MBeanServerConnection) getServer();
      ObjectName name = new ObjectName("jboss.security:service=JaasSecurityManager");
      JaasSecurityManagerServiceMBean secMgrService = (JaasSecurityManagerServiceMBean)
         MBeanServerInvocationHandler.newProxyInstance(conn, name, JaasSecurityManagerServiceMBean.class, false);

      // Access a secured servlet to create a session and jaas cache entry
      doSecureGetWithLogin("form-auth/restricted/SecuredServlet");

      // Validate that the jaas cache has 1 principal
      List principals = secMgrService.getAuthenticationCachePrincipals("jbossweb-form-auth");
      assertTrue("jbossweb-form-auth has one principal", principals.size() == 1);

      // Logout to clear the cache
      doSecureGet("form-auth/Logout");
      principals = secMgrService.getAuthenticationCachePrincipals("jbossweb-form-auth");
      log.info("jbossweb-form-auth principals = "+principals);
      assertTrue("jbossweb-form-auth has no cache principals", principals.size() == 0);
   }
View Full Code Here

Examples of org.jboss.security.plugins.JaasSecurityManagerServiceMBean

   public void testSecurityDomain() throws Exception
   {
      log.info("+++ testSecurityDomain, domain=spec-test");
      MBeanServerConnection conn = getServer();
      ObjectName secMgrName = new ObjectName("jboss.security:service=JaasSecurityManager");
      JaasSecurityManagerServiceMBean secMgr = (JaasSecurityManagerServiceMBean) MBeanServerInvocationHandler
            .newProxyInstance(conn, secMgrName, JaasSecurityManagerServiceMBean.class, false);

      // Test the spec-test security domain
      String domain = "spec-test";
      SimplePrincipal user = new SimplePrincipal("scott");
      boolean isValid = secMgr.isValid(domain, user, password);
      assertTrue("scott password is echoman", isValid);
      HashSet testRole = new HashSet();
      testRole.add(new SimplePrincipal("Echo"));
      boolean hasRole = secMgr.doesUserHaveRole(domain, user, password, testRole);
      assertTrue("scott has Echo role", hasRole);
      testRole.clear();
      testRole.add(new SimplePrincipal("EchoLocal"));
      hasRole = secMgr.doesUserHaveRole(domain, user, password, testRole);
      assertTrue("scott has EchoLocal role", hasRole);
      testRole.clear();
      testRole.add(new SimplePrincipal("ProjectUser"));
      hasRole = secMgr.doesUserHaveRole(domain, user, password, testRole);
      assertTrue("scott has ProjectUser role", hasRole);

      isValid = secMgr.isValid(domain, user, "badpass".toCharArray());
      assertTrue("badpass is an invalid password for scott", isValid == false);

      // Test the spec-test-domain security domain
      log.info("+++ testSecurityDomain, domain=spec-test-domain");
      domain = "spec-test-domain";
      isValid = secMgr.isValid(domain, user, password);
      assertTrue("scott password is echoman", isValid);
      hasRole = secMgr.doesUserHaveRole(domain, user, password, testRole);
      assertTrue("scott has Echo role", hasRole);
      testRole.clear();
      SimplePrincipal echoLocal = new SimplePrincipal("EchoLocal");
      testRole.add(echoLocal);
      hasRole = secMgr.doesUserHaveRole(domain, user, password, testRole);
      assertTrue("scott has EchoLocal role", hasRole);
      testRole.clear();
      SimplePrincipal projectUser = new SimplePrincipal("ProjectUser");
      testRole.add(projectUser);
      hasRole = secMgr.doesUserHaveRole(domain, user, password, testRole);
      assertTrue("scott has ProjectUser role", hasRole);
      Set roles = secMgr.getUserRoles(domain, user, password);
      assertTrue(roles != null);
      assertTrue("roles contains EchoLocal", roles.contains(echoLocal));
      assertTrue("roles contains ProjectUser", roles.contains(projectUser));

      isValid = secMgr.isValid(domain, user, "badpass".toCharArray());
      assertTrue("badpass is an invalid password for scott", isValid == false);
   }
View Full Code Here

Examples of org.jboss.security.plugins.JaasSecurityManagerServiceMBean

   {
      log.info("+++ testStressNoJaasCache, domain=spec-test");
      // Disable caching for the spec-test domain
      MBeanServerConnection conn = getServer();
      ObjectName secMgrName = new ObjectName("jboss.security:service=JaasSecurityManager");
      JaasSecurityManagerServiceMBean secMgr = (JaasSecurityManagerServiceMBean) MBeanServerInvocationHandler
            .newProxyInstance(conn, secMgrName, JaasSecurityManagerServiceMBean.class, false);
      secMgr.setCacheTimeout("spec-test", 0, 0);

      Exception failed = null;
      try
      {
         // Now execute the testStress access
         testStress();
      }
      catch (Exception e)
      {
         failed = e;
      }

      secMgr.setCacheTimeout("spec-test", 60, 60);
      if (failed != null)
         throw failed;
   }
View Full Code Here

Examples of org.jboss.security.plugins.JaasSecurityManagerServiceMBean

   public void testFlushOnSessionInvalidation() throws Exception
   {
      log.info("+++ testFlushOnSessionInvalidation");
      MBeanServerConnection conn = (MBeanServerConnection) getServer();
      ObjectName name = new ObjectName("jboss.security:service=JaasSecurityManager");
      JaasSecurityManagerServiceMBean secMgrService = (JaasSecurityManagerServiceMBean)
         MBeanServerInvocationHandler.newProxyInstance(conn, name, JaasSecurityManagerServiceMBean.class, false);

      // Access a secured servlet to create a session and jaas cache entry
      doSecureGetWithLogin("form-auth/restricted/SecuredServlet");

      // Validate that the jaas cache has 1 principal
      List principals = secMgrService.getAuthenticationCachePrincipals("jbossweb-form-auth");
      assertTrue("jbossweb-form-auth has one principal", principals.size() == 1);

      // Logout to clear the cache
      doSecureGet("form-auth/Logout");
      principals = secMgrService.getAuthenticationCachePrincipals("jbossweb-form-auth");
      log.info("jbossweb-form-auth principals = "+principals);
      assertTrue("jbossweb-form-auth has no cache principals", principals.size() == 0);
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.