Examples of SecurityClient


Examples of org.jboss.security.client.SecurityClient

    }

    @Test
    public void testStatelessLifecycle() throws Exception {
        deployer.deploy("slsb");
        SecurityClient client = this.login();
        try {
            ITestResultsSingleton results = this.getResultsSingleton();
            IBeanLifecycleCallback bean = (IBeanLifecycleCallback) initialContext.lookup("ejb:/slsb//" + SLSBLifecycleCallback.class.getSimpleName() + "!" + IBeanLifecycleCallback.class.getName());
            log.debug("Stateless bean returns: " + bean.get());

            Assert.assertEquals(OK + "start", results.getSlsb("postconstruct"));

            deployer.undeploy("slsb");

            Assert.assertEquals(OK + "stop", results.getSlsb("predestroy"));
        } finally {
            client.logout();
        }
    }
View Full Code Here

Examples of org.jboss.security.client.SecurityClient

    }

    @Test
    public void testStatefulLifecycle() throws Exception {
        deployer.deploy("sfsb");
        SecurityClient client = this.login();
        ITestResultsSingleton results = this.getResultsSingleton();
        try {
            IBeanLifecycleCallback bean = (IBeanLifecycleCallback) initialContext.lookup("ejb:/sfsb//" + SFSBLifecycleCallback.class.getSimpleName() + "!" + IBeanLifecycleCallback.class.getName() + "?stateful");
            log.debug("Stateful bean returns: " + bean.get());

            Assert.assertEquals(ANONYMOUS + "start", results.getSfsb("postconstruct"));

            bean.remove();

            Assert.assertEquals(LOCAL_USER +  "stop", results.getSfsb("predestroy"));
        } finally {
            deployer.undeploy("sfsb");
            client.logout();
        }
    }
View Full Code Here

Examples of org.jboss.security.client.SecurityClient

            }

            // Now set the security context, which can be used in EJB or other calls
            if (samlCredential != null)
            {
               SecurityClient client = SecurityClientFactory.getSecurityClient();
               // Simple login just updates the security context
               client.setSimple(new UserPrincipal(httpRequest.getRemoteUser()), samlCredential);
               client.login();

               if (log.isTraceEnabled())
               {
                  log.trace("SecurityClient successfully updated with SAMLCredential");
               }
View Full Code Here

Examples of org.jboss.security.client.SecurityClient

      super(name);
   }

   public void testSecurityClientFactory() throws Exception
   {
      SecurityClient sc = null;
      sc = SecurityClientFactory.getSecurityClient();
      assertNotNull("SecurityClient != null",sc);
      sc = SecurityClientFactory.getSecurityClient("org.jboss.security.client.JBossSecurityClient");
      assertNotNull("SecurityClient != null",sc);
      sc = SecurityClientFactory.getSecurityClient(JBossSecurityClient.class);
View Full Code Here

Examples of org.jboss.security.client.SecurityClient

       with only a EchoLocal cannot call the CallerBean.
    */
   public void testLocalEJBMethodAccessWithSimpleLogin() throws Exception
   {
      log.debug("+++ testLocalEJBMethodAccessWithSimpleLogin");
      SecurityClient sc = SecurityClientFactory.getSecurityClient(JBossSecurityClient.class);
      sc.setSimple("scott", "echoman".toCharArray());
      sc.login();
      InitialContext jndiContext = new InitialContext();
      Object obj = jndiContext.lookup("spec.CallerBean");
      obj = PortableRemoteObject.narrow(obj, CalledSessionHome.class);
      CalledSessionHome home = (CalledSessionHome) obj;
      log.debug("Found spec.CallerBean Home");
      CalledSession bean = home.create();
      log.debug("Created spec.CallerBean");
      log.debug("Bean.invokeEcho('testLocalMethodAccess') -> "+bean.invokeEcho("testLocalMethodAccess"));
      bean.remove();
      sc.logout();
   }
View Full Code Here

Examples of org.jboss.security.client.SecurityClient

   public void testLocalEJBMethodAccessWithJaasLogin() throws Exception
   {
      log.debug("+++ testLocalEJBMethodAccessWithJaasLogin");
      String confName = System.getProperty("conf.name", "spec-test");

      SecurityClient sc = SecurityClientFactory.getSecurityClient(JBossSecurityClient.class);
      AppCallbackHandler acbh = new AppCallbackHandler("scott","echoman".toCharArray());
      sc.setJAAS(confName, acbh);
      sc.login();
      InitialContext jndiContext = new InitialContext();
      Object obj = jndiContext.lookup("spec.CallerBean");
      obj = PortableRemoteObject.narrow(obj, CalledSessionHome.class);
      CalledSessionHome home = (CalledSessionHome) obj;
      log.debug("Found spec.CallerBean Home");
      CalledSession bean = home.create();
      log.debug("Created spec.CallerBean");
      log.debug("Bean.invokeEcho('testLocalMethodAccess') -> "+bean.invokeEcho("testLocalMethodAccess"));
      bean.remove();
      sc.logout();
   }
View Full Code Here

Examples of org.jboss.security.client.SecurityClient

    */
   public void testLocalEJBMethodAccessWithlogout() throws Exception
   {
      log.debug("+++ testLocalEJBMethodAccessWithlogout");

      SecurityClient sc = SecurityClientFactory.getSecurityClient(JBossSecurityClient.class);
      sc.logout();
      InitialContext jndiContext = new InitialContext();
      Object obj = jndiContext.lookup("spec.CallerBean");
      obj = PortableRemoteObject.narrow(obj, CalledSessionHome.class);
      CalledSessionHome home = (CalledSessionHome) obj;
      try
View Full Code Here

Examples of org.jboss.security.client.SecurityClient

   {
      try{
         log.info("TESTING XML Security");

         char[] password = "password".toCharArray();
         SecurityClient securityClient = SecurityClientFactory.getSecurityClient();
         setSecurity(securityClient,"somebody", password);
         //SecurityAssociation.pushSubjectContext(null, new SimplePrincipal("somebody"), password);

         log.info("testing unchecked constructor");
         SecuredPOJO pojo = new SecuredPOJO(); // unchecked construction
         log.info("testing unchecked method");
         pojo.unchecked();
         log.info("testing unchecked field");
         pojo.uncheckedField = 5;

         /*SecurityAssociation.popSubjectContext();
         SecurityAssociation.pushSubjectContext(null, new SimplePrincipal("authfail"), password);
*/
         securityClient.logout();
        
         setSecurity(securityClient,"authfail", password);
         
         boolean securityFailure = true;
         try
         {
            log.info("testing auth failure method");
            pojo.someMethod();
         }
         catch (SecurityException ignored)
         {
            log.info(ignored.getMessage());
            securityFailure = false;
         }

         if (securityFailure) throw new RuntimeException("auth failure was not caught for method");

         securityFailure = true;
         try
         {
            log.info("testing auth failure field");
            pojo.someField = 5;
         }
         catch (SecurityException ignored)
         {
            log.info(ignored.getMessage());
            securityFailure = false;
         }

         if (securityFailure) throw new RuntimeException("auth failure was not caught for field");
         securityFailure = true;
         try
         {
            log.info("testing auth failure constructor");
            pojo = new SecuredPOJO(4);
         }
         catch (SecurityException ignored)
         {
            log.info(ignored.getMessage());
            securityFailure = false;
         }

         if (securityFailure) throw new RuntimeException("auth failure was not caught for constructor");

         securityFailure = true;
        
         securityClient.logout();
         setSecurity(securityClient,"rolefail", password);
         /*
         SecurityAssociation.popSubjectContext();
         SecurityAssociation.pushSubjectContext(null, new SimplePrincipal("rolefail"), password);
         */
         try
         {
            log.info("testing role failure method");
            pojo.someMethod();
         }
         catch (SecurityException ignored)
         {
            log.info(ignored.getMessage());
            securityFailure = false;
         }
         if (securityFailure) throw new RuntimeException("role failure was not caught for method");

         securityFailure = true;
         try
         {
            log.info("testing role failure field");
            pojo.someField = 5;
         }
         catch (SecurityException ignored)
         {
            log.info(ignored.getMessage());
            securityFailure = false;
         }
         if (securityFailure) throw new RuntimeException("role failure was not caught field");

         securityFailure = true;
         try
         {
            log.info("testing role failure constructor");
            pojo = new SecuredPOJO(4);
         }
         catch (SecurityException ignored)
         {
            log.info(ignored.getMessage());
            securityFailure = false;
         }

         if (securityFailure) throw new RuntimeException("role failure was not caught for constructor");

         securityClient.logout();
         setSecurity(securityClient,"pass", password);
         /*
         SecurityAssociation.popSubjectContext();
         SecurityAssociation.pushSubjectContext(null, new SimplePrincipal("pass"), password);
         */
 
View Full Code Here

Examples of org.jboss.security.client.SecurityClient

   {
      try{
         log.info("TESTING Annotated Security");

         char[] password = "password".toCharArray();
         SecurityClient client = SecurityClientFactory.getSecurityClient();
         setSecurity(client,"somebody", password);

         log.info("testing unchecked constructor");
         AnnotatedSecuredPOJO pojo = new AnnotatedSecuredPOJO(); // unchecked construction
         log.info("testing unchecked method");
         pojo.unchecked();
         log.info("testing unchecked field");
         pojo.uncheckedField = 5;

         client.logout();
         setSecurity(client,"authfail", password);

         boolean securityFailure = true;
         try
         {
            log.info("testing auth failure method");
            pojo.someMethod();
         }
         catch (SecurityException ignored)
         {
            log.info(ignored.getMessage());
            securityFailure = false;
         }

         if (securityFailure) throw new RuntimeException("auth failure was not caught for method");

         securityFailure = true;
         try
         {
            log.info("testing auth failure field");
            pojo.someField = 5;
         }
         catch (SecurityException ignored)
         {
            log.info(ignored.getMessage());
            securityFailure = false;
         }

         if (securityFailure) throw new RuntimeException("auth failure was not caught for field");
         securityFailure = true;
         try
         {
            log.info("testing auth failure constructor");
            pojo = new AnnotatedSecuredPOJO(4);
         }
         catch (SecurityException ignored)
         {
            log.info(ignored.getMessage());
            securityFailure = false;
         }

         if (securityFailure) throw new RuntimeException("auth failure was not caught for constructor");

         securityFailure = true;
         client.logout();
         setSecurity(client,"rolefail", password);
         try
         {
            log.info("testing role failure method");
            pojo.someMethod();
         }
         catch (SecurityException ignored)
         {
            log.info(ignored.getMessage());
            securityFailure = false;
         }
         if (securityFailure) throw new RuntimeException("role failure was not caught for method");

         securityFailure = true;
         try
         {
            log.info("testing role failure field");
            pojo.someField = 5;
         }
         catch (SecurityException ignored)
         {
            log.info(ignored.getMessage());
            securityFailure = false;
         }
         if (securityFailure) throw new RuntimeException("role failure was not caught field");

         securityFailure = true;
         try
         {
            log.info("testing role failure constructor");
            pojo = new AnnotatedSecuredPOJO(4);
         }
         catch (SecurityException ignored)
         {
            log.info(ignored.getMessage());
            securityFailure = false;
         }

         if (securityFailure) throw new RuntimeException("role failure was not caught for constructor");

         client.logout();
         setSecurity(client,"pass", password);
        
         log.info("test pass");
         pojo.someMethod();
         pojo.someField = 5;
View Full Code Here

Examples of org.jboss.security.client.SecurityClient

   protected void processRequest(HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException
   {
      try
      {
         SecurityClient client = SecurityClientFactory.getSecurityClient();
         client.setSimple("somebody", "password");
         client.login();
        
         injectedSession.hello();
         injectedSession.goodbye();
        
         injectedStateful.hello();
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.