Examples of UsernamePasswordHandler


Examples of org.jboss.security.auth.callback.UsernamePasswordHandler

      lc.logout();
   }
   public void testLdapExample22() throws Exception
   {
      System.out.println("testLdapExample22");
      UsernamePasswordHandler handler = new UsernamePasswordHandler("jduke",
         "theduke".toCharArray());
      LoginContext lc = new LoginContext("testLdapExample22", handler);
      lc.login();

      Subject subject = lc.getSubject();
View Full Code Here

Examples of org.jboss.security.auth.callback.UsernamePasswordHandler

      lc.logout();
   }
   public void testLdapExample24() throws Exception
   {
      System.out.println("testLdapExample24");
      UsernamePasswordHandler handler = new UsernamePasswordHandler("Java Duke",
         "theduke".toCharArray());
      LoginContext lc = new LoginContext("testLdapExample24", handler);
      lc.login();

      Subject subject = lc.getSubject();
View Full Code Here

Examples of org.jboss.security.auth.callback.UsernamePasswordHandler

objectCategory: CN=Group,CN=Schema,CN=Configuration,DC=uz,DC=kuleuven,DC=ac,DC=be
    */
   public void testJBAS3312() throws Exception
   {
      System.out.println("testJBAS3312");
      UsernamePasswordHandler handler = new UsernamePasswordHandler("jduke",
         "theduke".toCharArray());
      LoginContext lc = new LoginContext("testJBAS3312", handler);
      lc.login();

      Subject subject = lc.getSubject();
View Full Code Here

Examples of org.jboss.security.auth.callback.UsernamePasswordHandler

      getLog().info("testXMLLoginModule options: "+entry[0].getOptions());
      AppConfigurationEntry[] entry2 = config.getAppConfigurationEntry("testXMLLoginModule2");
      assertTrue("Found testXMLLoginModule2", entry2 != null);
      getLog().info("testXMLLoginModule2 options: "+entry2[0].getOptions());

      UsernamePasswordHandler handler = new UsernamePasswordHandler("scott", "echoman".toCharArray());
      LoginContext lc = new LoginContext("testXMLLoginModule", handler);
      lc.login();
      Subject subject = lc.getSubject();
      Set groups = subject.getPrincipals(Group.class);
      assertTrue("Principals contains scott", subject.getPrincipals().contains(new SimplePrincipal("scott")));
      assertTrue("Principals contains Roles", groups.contains(new SimplePrincipal("Roles")));
      assertTrue("Principals contains CallerPrincipal", groups.contains(new SimplePrincipal("CallerPrincipal")));
      Group roles = (Group) groups.iterator().next();
      Iterator groupsIter = groups.iterator();
      while (groupsIter.hasNext())
      {
         roles = (Group) groupsIter.next();
         if (roles.getName().equals("Roles"))
         {
            assertTrue("Echo is a role", roles.isMember(new SimplePrincipal("Echo")));
            assertTrue("Java is NOT a role", roles.isMember(new SimplePrincipal("Java")) == false);
            assertTrue("Coder is NOT a role", roles.isMember(new SimplePrincipal("Coder")) == false);
         }
         else if (roles.getName().equals("CallerPrincipal"))
         {
            getLog().info("CallerPrincipal is " + roles.members().nextElement());
            boolean isMember = roles.isMember(new SimplePrincipal("callerScott"));
            assertTrue("CallerPrincipal is callerScott", isMember);
         }
      }
      lc.logout();

      handler = new UsernamePasswordHandler("stark", "javaman".toCharArray());
      lc = new LoginContext("testXMLLoginModule", handler);
      lc.login();
      subject = lc.getSubject();
      groups = subject.getPrincipals(Group.class);
      assertTrue("Principals contains stark", subject.getPrincipals().contains(new SimplePrincipal("stark")));
      assertTrue("Principals contains Roles", groups.contains(new SimplePrincipal("Roles")));
      assertTrue("Principals contains CallerPrincipal", groups.contains(new SimplePrincipal("CallerPrincipal")));
      groupsIter = groups.iterator();
      while (groupsIter.hasNext())
      {
         roles = (Group) groupsIter.next();
         if (roles.getName().equals("Roles"))
         {
            assertTrue("Echo is NOT a role", roles.isMember(new SimplePrincipal("Echo")) == false);
            assertTrue("Java is a role", roles.isMember(new SimplePrincipal("Java")));
            assertTrue("Coder is a role", roles.isMember(new SimplePrincipal("Coder")));
         }
         else if (roles.getName().equals("CallerPrincipal"))
         {
            getLog().info("CallerPrincipal is " + roles.members().nextElement());
            boolean isMember = roles.isMember(new SimplePrincipal("callerStark"));
            assertTrue("CallerPrincipal is callerStark", isMember);
         }
      }
      lc.logout();

      // Test the usernames with common prefix
      getLog().info("Testing similar usernames");
      handler = new UsernamePasswordHandler("jdukeman", "anotherduke".toCharArray());
      lc = new LoginContext("testXMLLoginModule", handler);
      lc.login();
      subject = lc.getSubject();
      groups = subject.getPrincipals(Group.class);
      assertTrue("Principals contains jdukeman", subject.getPrincipals().contains(new SimplePrincipal("jdukeman")));
      assertTrue("Principals contains Roles", groups.contains(new SimplePrincipal("Roles")));
      assertTrue("Principals contains CallerPrincipal", groups.contains(new SimplePrincipal("CallerPrincipal")));
      groupsIter = groups.iterator();
      while (groupsIter.hasNext())
      {
         roles = (Group) groupsIter.next();
         if (roles.getName().equals("Roles"))
         {
            assertTrue("Role1 is NOT a role", roles.isMember(new SimplePrincipal("Role1")) == false);
            assertTrue("Role2 is a role", roles.isMember(new SimplePrincipal("Role2")));
            assertTrue("Role3 is a role", roles.isMember(new SimplePrincipal("Role3")));
         }
         else if (roles.getName().equals("CallerPrincipal"))
         {
            getLog().info("CallerPrincipal is " + roles.members().nextElement());
            boolean isMember = roles.isMember(new SimplePrincipal("callerJdukeman"));
            assertTrue("CallerPrincipal is callerJdukeman", isMember);
         }
      }
      lc.logout();

      handler = new UsernamePasswordHandler("scott2", "echoman2".toCharArray());
      lc = new LoginContext("testXMLLoginModule2", handler);
      lc.login();
      subject = lc.getSubject();
      groups = subject.getPrincipals(Group.class);
      assertTrue("Principals contains scott2", subject.getPrincipals().contains(new SimplePrincipal("scott2")));
View Full Code Here

Examples of org.jboss.security.auth.callback.UsernamePasswordHandler

      XMLLoginConfigImpl config = XMLLoginConfigImpl.getInstance();
      config.setConfigResource("security/login-config2.xml");
      config.loadConfig();
      Configuration.setConfiguration(config);

      UsernamePasswordHandler handler = new UsernamePasswordHandler("jduke", "theduke".toCharArray());
      LoginContext lc = new LoginContext("testRoleMapping", handler);
      lc.login();
      Subject subject = lc.getSubject();
      Set groups = subject.getPrincipals(Group.class);
      assertTrue("Principals contains jduke", subject.getPrincipals().contains(new SimplePrincipal("jduke")));
      assertTrue("Principals contains Roles", groups.contains(new SimplePrincipal("Roles")));
      Group roles = (Group) groups.iterator().next();
      Iterator groupsIter = groups.iterator();
      while (groupsIter.hasNext())
      {
         roles = (Group) groupsIter.next();
         if (roles.getName().equals("Roles"))
         {
            assertTrue("Role2 is a role", roles.isMember(new SimplePrincipal("Role2")));
            assertTrue("Role3 is a role", roles.isMember(new SimplePrincipal("Role3")));
         }
      }
      lc.logout();

      handler = new UsernamePasswordHandler("jduke2", "theduke2".toCharArray());
      lc = new LoginContext("testRoleMapping", handler);
      lc.login();
      subject = lc.getSubject();
      groups = subject.getPrincipals(Group.class);
      assertTrue("Principals contains jduke2", subject.getPrincipals().contains(new SimplePrincipal("jduke2")));
View Full Code Here

Examples of org.jboss.security.auth.callback.UsernamePasswordHandler

   {
      Principal caller = context.getCallerPrincipal();
      String inputName = caller.getName();
      try
      {
         UsernamePasswordHandler handler = new UsernamePasswordHandler("clientLoginB1", "B1");
         LoginContext lc = new LoginContext("client-login", handler);
         lc.login();
         InitialContext ctx = new InitialContext();
         IClientLoginHome home = (IClientLoginHome) ctx.lookup("java:comp/env/TargetBean");
         IClientLogin bean = home.create();
         Principal callerB1 = bean.callTarget();
         if( callerB1.getName().equals("clientLoginB1") == false )
            throw new RemoteException("callBeanAsClientLoginUser#1 != clientLoginB1");
         lc.logout();

         handler = new UsernamePasswordHandler("clientLoginB2", "B2");
         lc = new LoginContext("client-login", handler);
         lc.login();
         Principal callerB2 = bean.callTarget();
         if( callerB2.getName().equals("clientLoginB2") == false )
            throw new RemoteException("callBeanAsClientLoginUser#2 != clientLoginB2");
View Full Code Here

Examples of org.jboss.security.auth.callback.UsernamePasswordHandler

   {
      Principal caller = context.getCallerPrincipal();
      String inputName = caller.getName();
      try
      {
         UsernamePasswordHandler handler = new UsernamePasswordHandler("clientLoginA1", "A1");
         LoginContext lc = new LoginContext("client-login", handler);
         lc.login();
         InitialContext ctx = new InitialContext();
         IClientLoginHome home = (IClientLoginHome) ctx.lookup("java:comp/env/TargetBean");
         IClientLogin bean = home.create();
         Principal callerB1 = bean.callBeanAsClientLoginUser();
         if( callerB1.getName().equals("clientLoginA1") == false )
            throw new RemoteException("callBeanAsClientLoginUser#1 != clientLoginA1");
         lc.logout();

         handler = new UsernamePasswordHandler("clientLoginA2", "A2");
         lc = new LoginContext("client-login", handler);
         lc.login();
         Principal callerB2 = bean.callBeanAsClientLoginUser();
         if( callerB2.getName().equals("clientLoginA2") == false )
            throw new RemoteException("callBeanAsClientLoginUser#2 != clientLoginA2");
View Full Code Here

Examples of org.jboss.security.auth.callback.UsernamePasswordHandler

   }

   public void testClientLogin() throws Exception
   {
      log.info("testClientLogin");
      UsernamePasswordHandler handler = new UsernamePasswordHandler("scott", "secret".toCharArray());
      LoginContext lc = new LoginContext("testClientLogin", handler);
      lc.login();
      Subject subject = lc.getSubject();
      Principal scott = new SimplePrincipal("scott");
      assertTrue("Principals contains scott", subject.getPrincipals().contains(scott));
      Principal saPrincipal = SecurityAssociation.getPrincipal();
      assertTrue("SecurityAssociation.getPrincipal == scott", saPrincipal.equals(scott));

      UsernamePasswordHandler handler2 = new UsernamePasswordHandler("scott2", "secret2".toCharArray());
      LoginContext lc2 = new LoginContext("testClientLogin", handler2);
      lc2.login();
      Principal scott2 = new SimplePrincipal("scott2");
      saPrincipal = SecurityAssociation.getPrincipal();
      assertTrue("SecurityAssociation.getPrincipal == scott2", saPrincipal.equals(scott2));
View Full Code Here

Examples of org.jboss.security.auth.callback.UsernamePasswordHandler

   }

   public void testUsernamePassword() throws Exception
   {
      log.info("testUsernamePassword");
      UsernamePasswordHandler handler = new UsernamePasswordHandler("scott", "secret".toCharArray());
      LoginContext lc = new LoginContext("testUsernamePassword", handler);
      lc.login();
      Subject subject = lc.getSubject();
      Set groups = subject.getPrincipals(Group.class);
      assertTrue("Principals contains scott", subject.getPrincipals().contains(new SimplePrincipal("scott")));
View Full Code Here

Examples of org.jboss.security.auth.callback.UsernamePasswordHandler

      lc.logout();
   }
   public void testUsernamePasswordHash() throws Exception
   {
      log.info("testUsernamePasswordHash");
      UsernamePasswordHandler handler = new UsernamePasswordHandler("scott", "secret".toCharArray());
      LoginContext lc = new LoginContext("testUsernamePasswordHash", handler);
      lc.login();
      Subject subject = lc.getSubject();
      Set groups = subject.getPrincipals(Group.class);
      assertTrue("Principals contains scott", subject.getPrincipals().contains(new SimplePrincipal("scott")));
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.