Package org.apache.wiki.auth

Examples of org.apache.wiki.auth.WikiPrincipal


        }
    }

    public final void testLogout()
    {
        Principal principal = new WikiPrincipal( "Andrew Jaquith" );
        MockHttpServletRequest request = m_engine.newHttpRequest();
        request.setUserPrincipal( principal );
        try
        {
            CallbackHandler handler = new WebContainerCallbackHandler( m_engine, request );
View Full Code Here


                              new HashMap<String, Object>() );
            module.login();
            module.commit();
            Set principals = m_subject.getPrincipals();
            assertEquals( 1, principals.size() );
            assertTrue( principals.contains( new WikiPrincipal( "user", WikiPrincipal.LOGIN_NAME ) ) );
            assertFalse( principals.contains( Role.AUTHENTICATED ) );
            assertFalse( principals.contains( Role.ALL ) );
           
            // Login with a user that IS in the database
            m_subject = new Subject();
            handler = new WikiCallbackHandler( m_engine, null, "janne", "myP@5sw0rd" );
            module = new UserDatabaseLoginModule();
            module.initialize( m_subject, handler,
                              new HashMap<String, Object>(),
                              new HashMap<String, Object>() );
            module.login();
            module.commit();
            principals = m_subject.getPrincipals();
            assertEquals( 1, principals.size() );
            assertTrue( principals.contains( new WikiPrincipal( "janne", WikiPrincipal.LOGIN_NAME ) ) );
            assertFalse( principals.contains( Role.AUTHENTICATED ) );
            assertFalse( principals.contains( Role.ALL ) );           
        }
        catch( LoginException e )
        {
View Full Code Here

                              new HashMap<String, Object>() );
            module.login();
            module.commit();
            Set principals = m_subject.getPrincipals();
            assertEquals( 1, principals.size() );
            assertTrue( principals.contains( new WikiPrincipal( "user",  WikiPrincipal.LOGIN_NAME ) ) );
            assertFalse( principals.contains( Role.AUTHENTICATED ) );
            assertFalse( principals.contains( Role.ALL ) );
            module.logout();
            assertEquals( 0, principals.size() );
        }
View Full Code Here

                              new HashMap<String, Object>() );
            module.login();
            module.commit();
            Set principals = m_subject.getPrincipals();
            assertEquals( 1, principals.size() );
            assertTrue( principals.contains( new WikiPrincipal( "Bullwinkle" ) ) );
            assertFalse( principals.contains( Role.ASSERTED ) );
            assertFalse( principals.contains( Role.ALL ) );
        }
        catch( LoginException e )
        {
View Full Code Here

                              new HashMap<String, Object>() );
            module.login();
            module.commit();
            Set principals = m_subject.getPrincipals();
            assertEquals( 1, principals.size() );
            assertTrue( principals.contains( new WikiPrincipal( "Bullwinkle" ) ) );
            assertFalse( principals.contains( Role.ANONYMOUS ) );
            assertFalse( principals.contains( Role.ALL ) );
            module.logout();
            assertEquals( 0, principals.size() );
        }
View Full Code Here

            module.initialize( m_subject, handler, new HashMap<String, Object>(), new HashMap<String, Object>() );
            module.login();
            module.commit();
            Set principals = m_subject.getPrincipals();
            assertEquals( 1, principals.size() );
            assertTrue( principals.contains( new WikiPrincipal( "127.0.0.1" ) ) );
            assertFalse( principals.contains( Role.ANONYMOUS ) );
            assertFalse( principals.contains( Role.ALL ) );
        }
        catch( LoginException e )
        {
View Full Code Here

                              new HashMap<String, Object>() );
            module.login();
            module.commit();
            Set principals = m_subject.getPrincipals();
            assertEquals( 1, principals.size() );
            assertTrue( principals.contains( new WikiPrincipal( "127.0.0.1" ) ) );
            assertFalse( principals.contains( Role.ANONYMOUS ) );
            assertFalse( principals.contains( Role.ALL ) );
            module.logout();
            assertEquals( 0, principals.size() );
        }
View Full Code Here

      int oldUserCount = m_db.groups().length;

      // Create a new group with random name
      String name = "TestGroup" + String.valueOf( System.currentTimeMillis() );
      Group group = new Group( name, m_wiki );
      Principal al = new WikiPrincipal( "Al" );
      Principal bob = new WikiPrincipal( "Bob" );
      group.add( al );
      group.add( bob );
      m_db.save(group, new WikiPrincipal( "Tester") );

      // Make sure the profile saved successfully
      group = backendGroup( name );
      assertEquals( name, group.getName() );
      assertEquals( oldUserCount+1, m_db.groups().length );
View Full Code Here

  public void testSave() throws Exception
  {
      // Create a new group with random name
      String name = "TestGroup" + String.valueOf( System.currentTimeMillis() );
      Group group = new Group( name, m_wiki );
      Principal al = new WikiPrincipal( "Al" );
      Principal bob = new WikiPrincipal( "Bob" );
      Principal cookie = new WikiPrincipal( "Cookie" );
      group.add( al );
      group.add( bob );
      group.add( cookie );
      m_db.save(group, new WikiPrincipal( "Tester" ) );

      // Make sure the profile saved successfully
      group = backendGroup( name );
      assertEquals( name, group.getName() );
      assertEquals( 3, group.members().length );
      assertTrue( group.isMember( new WikiPrincipal( "Al" ) ) );
      assertTrue( group.isMember( new WikiPrincipal( "Bob" ) ) );
      assertTrue( group.isMember( new WikiPrincipal( "Cookie" ) ) );

      // The back-end should have timestamped the create/modify fields
      assertNotNull( group.getCreator() );
      assertEquals( "Tester", group.getCreator() );
      assertNotNull( group.getCreated() );
View Full Code Here

  public void testResave() throws Exception
  {
      // Create a new group with random name & 3 members
      String name = "TestGroup" + String.valueOf( System.currentTimeMillis() );
      Group group = new Group( name, m_wiki );
      Principal al = new WikiPrincipal( "Al" );
      Principal bob = new WikiPrincipal( "Bob" );
      Principal cookie = new WikiPrincipal( "Cookie" );
      group.add( al );
      group.add( bob );
      group.add( cookie );
      m_db.save(group, new WikiPrincipal( "Tester" ) );

      // Make sure the profile saved successfully
      group = backendGroup( name );
      assertEquals( name, group.getName() );

      // Modify the members by adding the group; re-add Al while we're at it
      Principal dave = new WikiPrincipal( "Dave" );
      group.add( al );
      group.add( dave );
      m_db.save(group, new WikiPrincipal( "SecondTester" ) );

      // We should see 4 members and new timestamp info
      Principal[] members = group.members();
      assertEquals( 4, members.length );
      assertNotNull( group.getCreator() );
View Full Code Here

TOP

Related Classes of org.apache.wiki.auth.WikiPrincipal

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.