Package org.apache.wiki.auth

Examples of org.apache.wiki.auth.WikiPrincipal


        assertEquals( "[{ALLOW edit Charlie,Herman}]\n", aclString );

        // Create an ACL from scratch
        acl = new AclImpl();
        AclEntry entry = new AclEntryImpl();
        entry.setPrincipal( new WikiPrincipal( "Charlie" ) );
        entry.addPermission( PermissionFactory.getPagePermission( "Main:Foo", "view" ) );
        entry.addPermission( PermissionFactory.getPagePermission( "Main:Foo", "edit" ) );
        acl.addEntry( entry );
        entry = new AclEntryImpl();
        entry.setPrincipal( new WikiPrincipal( "Devin" ) );
        entry.addPermission( PermissionFactory.getPagePermission( "Main:Foo", "edit" ) );
        entry.addPermission( PermissionFactory.getPagePermission( "Main:Foo", "delete" ) );
        acl.addEntry( entry );

        // Verify that the printed ACL is OK
View Full Code Here


        MockHttpServletRequest request;
        WikiSession wikiSession;
       
        // Changing the UserPrincipal value should cause the user to be authenticated...
        request = m_engine.newHttpRequest();
        request.setUserPrincipal( new WikiPrincipal( "Fred Flintstone") );
        runSecurityFilter(m_engine, request);
        wikiSession = WikiSession.getWikiSession( m_engine, request );
        assertTrue( wikiSession.isAuthenticated());
        assertEquals( "Fred Flintstone", wikiSession.getUserPrincipal().getName() );
    }
View Full Code Here

        for ( int i = 0; i < roles.length; i++ )
        {
            r.add( roles[i].getName() );
        }
        request.setRoles( r );
        request.setUserPrincipal( new WikiPrincipal( id ) );
       
        // Log in
        runSecurityFilter(engine,request);
       
        // Make sure the user is actually authenticated
View Full Code Here

    Decision m_decision;

    protected void setUp() throws Exception
    {
        super.setUp();
        m_workflow = new Workflow("workflow.key", new WikiPrincipal("Owner1"));
        m_decision = new SimpleDecision(m_workflow, "decision.key", new WikiPrincipal("Actor1"));
    }
View Full Code Here

        assertEquals(f3, facts.get(2));
    }

    public void testGetActor()
    {
       assertEquals(new WikiPrincipal("Actor1"), m_decision.getActor());
    }
View Full Code Here

        assertTrue(m_decision.isReassignable());
    }

    public void testReassign()
    {
        m_decision.reassign(new WikiPrincipal("Actor2"));
        assertEquals(new WikiPrincipal("Actor2"), m_decision.getActor());
    }
View Full Code Here

    }

    public void testSuccessors()
    {
        // If the decision is approved, branch to another decision (d2)
        Step d2 = new SimpleDecision(m_workflow, "decision2.key", new WikiPrincipal("Actor1"));
        m_decision.addSuccessor(Outcome.DECISION_APPROVE, d2);

        // If the decision is denied, branch to another decision (d3)
        Step d3 = new SimpleDecision(m_workflow, "decision3.key", new WikiPrincipal("Actor1"));
        m_decision.addSuccessor(Outcome.DECISION_DENY, d3);

        assertEquals(d2, m_decision.getSuccessor(Outcome.DECISION_APPROVE));
        assertEquals(d3, m_decision.getSuccessor(Outcome.DECISION_DENY));
View Full Code Here

        Properties props = new Properties();
        props.load(TestEngine.findTestProperties());
        m_engine = new TestEngine(props);
        wm = m_engine.getWorkflowManager();
        // Create a workflow with 3 steps, with a Decision in the middle
        w = new Workflow("workflow.key", new WikiPrincipal("Owner1"));
        w.setWorkflowManager(m_engine.getWorkflowManager());
        Step startTask = new TaskTest.NormalTask(w);
        Step endTask = new TaskTest.NormalTask(w);
        Decision decision = new SimpleDecision(w, "decision.editWikiApproval", new WikiPrincipal("Actor1"));
        startTask.addSuccessor(Outcome.STEP_COMPLETE, decision);
        decision.addSuccessor(Outcome.DECISION_APPROVE, endTask);
        w.setFirstStep(startTask);
       
        // Add a message argument to the workflow with the page name
View Full Code Here

    }

    public void testGetApprover() throws WikiException
    {
        // Test properties says workflow.saveWikiPage approver is GP Admin; workflow.foo is 'janne'
        assertEquals(new WikiPrincipal("janne", WikiPrincipal.LOGIN_NAME), wm.getApprover("workflow.foo"));
        assertEquals(new GroupPrincipal("Admin"), wm.getApprover("workflow.bar"));
       
        // 'saveWikiPage' workflow doesn't require approval, so we will need to catch an Exception
        try
        {
View Full Code Here


    public void testBuildApprovalWorkflow() throws WikiException
    {

        Principal submitter = new WikiPrincipal( "Submitter" );
        String workflowApproverKey = "workflow.approvalWorkflow";
        Task prepTask = new TestPrepTask( "task.preSaveWikiPage" );
        String decisionKey = "decision.saveWikiPage";
        Fact[] facts = new Fact[3];
        facts[0] = new Fact("fact1",new Integer(1));
        facts[1] = new Fact("fact2","A factual String");
        facts[2] = new Fact("fact3",Outcome.DECISION_ACKNOWLEDGE);
        Task completionTask = new TestPrepTask( "task.saveWikiPage" );
        String rejectedMessageKey = "notification.saveWikiPage.reject";

        Workflow w = m_builder.buildApprovalWorkflow(submitter, workflowApproverKey,
                                                   prepTask, decisionKey, facts,
                                                   completionTask, rejectedMessageKey);
        w.setWorkflowManager( m_engine.getWorkflowManager() );

        // Check to see if the workflow built correctly
        assertFalse( w.isStarted() || w.isCompleted() || w.isAborted() );
        assertNull( w.getCurrentStep() );
        assertEquals( "workflow.approvalWorkflow", w.getMessageKey() );
        assertEquals( Workflow.CREATED, w.getCurrentState() );
        assertEquals( new WikiPrincipal("Submitter"), w.getOwner() );
        assertEquals( m_engine.getWorkflowManager(), w.getWorkflowManager() );
        assertEquals( 0, w.getHistory().size() );

        // Our dummy "task complete" attributes should still be null
        assertNull( w.getAttribute( "task.preSaveWikiPage") );
        assertNull( w.getAttribute( "task.saveWikiPage") );

        // Start the workflow
        w.start();

        // Presave complete attribute should be set now, and current step should be Decision
        Step decision = w.getCurrentStep();
        assertTrue( decision instanceof Decision );
        assertEquals( 2, w.getHistory().size() );
        assertEquals( prepTask, w.getHistory().get( 0 ) );
        assertTrue( w.getHistory().get( 1 ) instanceof Decision );
        assertNotNull( w.getAttribute( "task.preSaveWikiPage") );
        assertEquals( new WikiPrincipal( Users.JANNE ), decision.getActor() );
        assertEquals( decisionKey, decision.getMessageKey() );
        List decisionFacts = ((Decision)decision).getFacts();
        assertEquals( 3, decisionFacts.size() );
        assertEquals( facts[0], decisionFacts.get(0) );
        assertEquals( facts[1], decisionFacts.get(1) );
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.