Package org.jboss.security.identity

Examples of org.jboss.security.identity.Identity


               Principal userPrincipal = sc.getUtil().getUserPrincipal();
               String unauthenticatedPrincipal = domain.unauthenticatedPrincipal();
               if(userPrincipal == null && unauthenticatedPrincipal !=null &&
                     unauthenticatedPrincipal.length() > 0)
               {
                  Identity unauthenticatedIdentity = new SimpleIdentity(unauthenticatedPrincipal);
                  sc.getSubjectInfo().addIdentity(unauthenticatedIdentity);
                  subject.getPrincipals().add(unauthenticatedIdentity.asPrincipal());
               }
               else
               {
                  //Authenticate the caller now
                  if(!helper.isValid(subject, method.getName()))
View Full Code Here


   private static final PersistenceStrategy ps = new FilePersistenceStrategy(path);

   public void testWriteIdentity() throws Exception
   {
      Identity identity = IdentityFactory.createIdentity(identityName);
      assertFalse("File already exists", file.exists());
      assertNotNull("Failed to persist", ps.persistIdentity(identity));
      assertTrue("File was not created", file.exists());
   }
View Full Code Here

      assertTrue("File was not created", file.exists());
   }

   public void testReadIdentity() throws Exception
   {
      Identity identity = IdentityFactory.createIdentity(identityName);
      assertFalse("File already exists", file.exists());
      assertNotNull("Failed to persist", ps.persistIdentity(identity));
      assertTrue("File was not created", file.exists());

      Identity restored = ps.getIdentity(identityName);
      assertEquals("Objects are different", identity, restored);
   }
View Full Code Here

      assertEquals("Objects are different", identity, restored);
   }

   public void testReadIdentityWithRole() throws Exception
   {
      Identity identity = IdentityFactory.createIdentityWithRole(identityName, "testRole");
      assertFalse("File already exists", file.exists());
      assertNotNull("Failed to persist", ps.persistIdentity(identity));
      assertTrue("File was not created", file.exists());

      Identity restored = ps.getIdentity(identityName);
      assertEquals("Objects are different", identity, restored);
      assertEquals("Role names are different", identity.getRole().getRoleName(), restored.getRole().getRoleName());
   }
View Full Code Here

   public void testReadIdentityWithRoleAndParent() throws Exception
   {
      Role parent = new SimpleRole("parent");
      Role role = new SimpleRole("testRole", parent);
      Identity identity = IdentityFactory.createIdentityWithRole(identityName, role);
      assertFalse("File already exists", file.exists());
      assertNotNull("Failed to persist", ps.persistIdentity(identity));
      assertTrue("File was not created", file.exists());

      Identity restored = ps.getIdentity(identityName);
      assertEquals("Objects are different", identity, restored);
      assertEquals("Role names are different", identity.getRole().getRoleName(), restored.getRole().getRoleName());
      assertEquals("Parent role names are different", identity.getRole().getParent().getRoleName(), restored.getRole()
            .getParent().getRoleName());
   }
View Full Code Here

            .getParent().getRoleName());
   }

   public void testRemoveIdentity() throws Exception
   {
      Identity identity = IdentityFactory.createIdentity(identityName);
      assertFalse("File already exists", file.exists());
      assertNotNull("Failed to persist", ps.persistIdentity(identity));
      assertTrue("File was not created", file.exists());

      assertTrue("Identity was not removed", ps.removeIdentity(identity));
View Full Code Here

      assertTrue("Identity was not removed", ps.removeIdentity(identity));
   }

   public void testUpdateIdentityWithRole() throws Exception
   {
      Identity identity = IdentityFactory.createIdentity(identityName);
      assertFalse("File already exists", file.exists());
      assertNotNull("Failed to persist", ps.persistIdentity(identity));
      assertTrue("File was not created", file.exists());

      Identity restored = ps.getIdentity(identityName);
      assertEquals("Objects are different", identity, restored);
      assertNull("Role must be null", restored.getRole());

      identity = IdentityFactory.createIdentityWithRole(identityName, "testRole");
      ps.updateIdentity(identity);
      assertTrue("File was not re-created", file.exists());
      restored = ps.getIdentity(identityName);
      assertEquals("Objects are different", identity, restored);
      assertEquals("Role names are different", identity.getRole().getRoleName(), restored.getRole().getRoleName());
   }
View Full Code Here

      assertEquals("Role names are different", identity.getRole().getRoleName(), restored.getRole().getRoleName());
   }

   public void testWriteDuplicateIdentity() throws Exception
   {
      Identity identity = IdentityFactory.createIdentity(identityName);
      assertFalse("File already exists", file.exists());
      assertNotNull("Failed to persist", ps.persistIdentity(identity));
      assertTrue("File was not created", file.exists());

      Identity duplicate = IdentityFactory.createIdentity(identityName);
      assertNull("Should not persist duplicate Identity", ps.persistIdentity(duplicate));
   }
View Full Code Here

public class IdentityUnitTestCase extends TestCase
{
   public void testSetIdentity() throws Exception
   {
      SecurityContext sc = SecurityContextFactory.createSecurityContext("Test");
      Identity i1 = new Identity1();
      Identity i2 = new Identity2();
     
      SecurityContextUtil util = sc.getUtil();
     
      util.addIdentity(i1);
      util.addIdentity(i2);
View Full Code Here

   {
      AccessController.doPrivileged(new PrivilegedExceptionAction<Object>()
      {
         public Object run() throws Exception
         {
            Identity identity = new SimpleIdentity(principal.getName());

            SecurityContext sc = getSecurityContext();
            if(sc == null)
            {
              sc = createSecurityContext();
View Full Code Here

TOP

Related Classes of org.jboss.security.identity.Identity

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.