Package org.apache.wiki.auth

Examples of org.apache.wiki.auth.WikiPrincipal


            {
                log.warn( "Detected null wiki name in XMLUserDataBase. Check your user database." );
            }
            else
            {
                Principal principal = new WikiPrincipal( wikiName, WikiPrincipal.WIKI_NAME );
                principals.add( principal );
            }
        }
        return principals.toArray( new Principal[principals.size()] );
    }
View Full Code Here


        WikiSecurityEvent se = (WikiSecurityEvent) event;
        if (se.getType() == WikiSecurityEvent.PROFILE_NAME_CHANGED) {
            UserProfile[] profiles = (UserProfile[]) se.getTarget();
            Principal[] oldPrincipals = new Principal[]
                    {new WikiPrincipal(profiles[0].getLoginName()),
                            new WikiPrincipal(profiles[0].getFullname()),
                            new WikiPrincipal(profiles[0].getWikiName())};
            Principal newPrincipal = new WikiPrincipal(profiles[1].getFullname());

            // Examine each page ACL
            try {
                int pagesChanged = 0;
                Collection pages = getAllPages();
                for (Iterator it = pages.iterator(); it.hasNext(); ) {
                    WikiPage page = (WikiPage) it.next();
                    boolean aclChanged = changeAcl(page, oldPrincipals, newPrincipal);
                    if (aclChanged) {
                        // If the Acl needed changing, change it now
                        try {
                            m_engine.getAclManager().setPermissions(page, page.getAcl());
                        } catch (WikiSecurityException e) {
                            log.error("Could not change page ACL for page " + page.getName() + ": " + e.getMessage(), e);
                        }
                        pagesChanged++;
                    }
                }
                log.info("Profile name change for '" + newPrincipal.toString() +
                        "' caused " + pagesChanged + " page ACLs to change also.");
            } catch (ProviderException e) {
                // Oooo! This is really bad...
                log.error("Could not change user name in Page ACLs because of Provider error:" + e.getMessage(), e);
            }
View Full Code Here

                {
                    log.warn( "Detected null wiki name in XMLUserDataBase. Check your user database." );
                }
                else
                {
                    Principal principal = new WikiPrincipal( wikiName, WikiPrincipal.WIKI_NAME );
                    principals.add( principal );
                }
            }
            ps.close();
        }
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

            while ( rs.next() )
            {
                String memberName = rs.getString( m_member );
                if( memberName != null )
                {
                    WikiPrincipal principal = new WikiPrincipal( memberName, WikiPrincipal.UNSPECIFIED );
                    group.add( principal );
                }
            }
        }
        catch( SQLException e )
View Full Code Here

        if ( members.length > 0 )
        {
            group.clear();
            for( String member : members )
            {
                group.add( new WikiPrincipal( member ) );
            }
        }

        return group;
    }
View Full Code Here

        if ( se.getType() == WikiSecurityEvent.PROFILE_NAME_CHANGED )
        {
            WikiSession session = se.getSrc();
            UserProfile[] profiles = (UserProfile[])se.getTarget();
            Principal[] oldPrincipals = new Principal[] {
                new WikiPrincipal( profiles[0].getLoginName() ),
                new WikiPrincipal( profiles[0].getFullname() ),
                new WikiPrincipal( profiles[0].getWikiName() ) };
            Principal newPrincipal = new WikiPrincipal( profiles[1].getFullname() );

            // Examine each group
            int groupsChanged = 0;
            try
            {
                for ( Group group : m_groupDatabase.groups() )
                {
                    boolean groupChanged = false;
                    for ( Principal oldPrincipal : oldPrincipals )
                    {
                        if ( group.isMember( oldPrincipal ) )
                        {
                            group.remove( oldPrincipal );
                            group.add( newPrincipal );
                            groupChanged = true;
                        }
                    }
                    if ( groupChanged )
                    {
                        setGroup( session, group );
                        groupsChanged++;
                    }
                }
            }
            catch ( WikiException e )
            {
                // Oooo! This is really bad...
                log.error( "Could not change user name in Group lists because of GroupDatabase error:" + e.getMessage() );
            }
            log.info( "Profile name change for '" + newPrincipal.toString() +
                      "' caused " + groupsChanged + " groups to change also." );
        }
    }
View Full Code Here

        NodeList members = groupNode.getElementsByTagName( MEMBER_TAG );
        for( int i = 0; i < members.getLength(); i++ )
        {
            Element memberNode = (Element) members.item( i );
            String principalName = memberNode.getAttribute( PRINCIPAL );
            Principal member = new WikiPrincipal( principalName );
            group.add( member );
        }

        // Add the created/last-modified info
        String creator = groupNode.getAttribute( CREATOR );
View Full Code Here

        Principal[] p;

        // Charlie is an editor; reading is therefore implied
        p = acl.findPrincipals( PermissionFactory.getPagePermission(page, "view") );
        assertEquals( 2, p.length );
        assertTrue( ArrayUtils.contains( p, new WikiPrincipal("Charlie") ) );

        // Charlie should be in the ACL as an editor
        p = acl.findPrincipals( PermissionFactory.getPagePermission(page, "edit") );
        assertEquals( 2, p.length );
        assertTrue( ArrayUtils.contains( p, new WikiPrincipal("Charlie") ) );

        // Charlie should not be able to delete this page
        p = acl.findPrincipals( PermissionFactory.getPagePermission(page, "delete") );
        assertEquals( 0, p.length );
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.