Examples of UnresolvedPrincipal


Examples of org.apache.harmony.security.UnresolvedPrincipal

    }

    public void testImplies() {
        String name = "sgrt";
        FakePrincipal fp = new FakePrincipal(name);
        assertTrue(new UnresolvedPrincipal(FakePrincipal.class.getName(), name)
            .implies(fp));
        assertTrue(new UnresolvedPrincipal(UnresolvedPrincipal.WILDCARD, name)
            .implies(fp));
        assertTrue(new UnresolvedPrincipal(FakePrincipal.class.getName(),
            UnresolvedPrincipal.WILDCARD).implies(fp));
        assertTrue(new UnresolvedPrincipal(UnresolvedPrincipal.WILDCARD,
            UnresolvedPrincipal.WILDCARD).implies(fp));

        assertFalse(new UnresolvedPrincipal(
            UnresolvedPrincipal.class.getName(), name).implies(fp));
        assertFalse(new UnresolvedPrincipal(FakePrincipal.class.getName(),
            "hgfuytr765").implies(fp));
    }
View Full Code Here

Examples of org.apache.harmony.security.UnresolvedPrincipal

            new Principal[] { new FakePrincipal("qqq") });

        PolicyEntry pe1 = new PolicyEntry(cs, null, Arrays
            .asList(new Permission[] { sp1 }));
        PolicyEntry pe2 = new PolicyEntry(cs2, Arrays
            .asList(new Principal[] { new UnresolvedPrincipal(
                UnresolvedPrincipal.WILDCARD, UnresolvedPrincipal.WILDCARD) }),
            Arrays.asList(new Permission[] { sp2 }));
        PolicyEntry pe3 = new PolicyEntry(cs, Arrays
            .asList(new Principal[] { new UnresolvedPrincipal(
                FakePrincipal.class.getName(), "qqq") }), Arrays
            .asList(new Permission[] { sp3 }));
        PolicyEntry pe4 = new PolicyEntry(cs2, Arrays
            .asList(new Principal[] { new UnresolvedPrincipal(
                FakePrincipal.class.getName(), "ttt") }), Arrays
            .asList(new Permission[] { sp4 }));
        PolicyEntry[] peArray = new PolicyEntry[] {
            pe1, pe2, pe3, pe4 };
        DefaultPolicy policy = new DefaultPolicy(new TestParser(peArray));
View Full Code Here

Examples of org.apache.wiki.auth.acl.UnresolvedPrincipal

        // We shouldn't be able to spoof a built-in role
        assertNotSame( new WikiPrincipal( "Authenticated" ), m_auth.resolvePrincipal( "Authenticated" ) );

        // An unknown user should resolve to a generic UnresolvedPrincipal
        Principal principal = new UnresolvedPrincipal( "Bart Simpson" );
        assertEquals( principal, m_auth.resolvePrincipal( "Bart Simpson" ) );
    }
View Full Code Here

Examples of org.apache.wiki.auth.acl.UnresolvedPrincipal

     */
    public Principal resolvePrincipal( String name )
    {
        if( !m_useJAAS )
        {
            return new UnresolvedPrincipal(name);
        }

        // Check built-in Roles first
        Role role = new Role(name);
        if ( Role.isBuiltInRole( role ) )
        {
            return role;
        }

        // Check Authorizer Roles
        Principal principal = m_authorizer.findRole( name );
        if ( principal != null )
        {
            return principal;
        }

        // Check Groups
        principal = m_engine.getGroupManager().findRole( name );
        if ( principal != null )
        {
            return principal;
        }

        // Ok, no luck---this must be a user principal
        Principal[] principals = null;
        UserProfile profile = null;
        UserDatabase db = m_engine.getUserManager().getUserDatabase();
        try
        {
            profile = db.find( name );
            principals = db.getPrincipals( profile.getLoginName() );
            for (int i = 0; i < principals.length; i++)
            {
                principal = principals[i];
                if ( principal.getName().equals( name ) )
                {
                    return principal;
                }
            }
        }
        catch( NoSuchPrincipalException e )
        {
            // We couldn't find the user...
        }
        // Ok, no luck---mark this as unresolved and move on
        return new UnresolvedPrincipal( name );
    }
View Full Code Here

Examples of org.apache.wiki.auth.acl.UnresolvedPrincipal

                    // Only use non-null/non-blank approvers
                    String approver = props.getProperty( prop );
                    if ( approver != null && approver.length() > 0 )
                    {
                        m_approvers.put( key, new UnresolvedPrincipal( approver ) );
                    }
                }
            }
        }
    }
View Full Code Here

Examples of org.apache.wiki.auth.acl.UnresolvedPrincipal

                    // Only use non-null/non-blank approvers
                    String approver = props.getProperty( prop );
                    if ( approver != null && approver.length() > 0 )
                    {
                        m_approvers.put( key, new UnresolvedPrincipal( approver ) );
                    }
                }
            }
        }
    }
View Full Code Here

Examples of org.apache.wiki.auth.acl.UnresolvedPrincipal

     */
    public final Principal resolvePrincipal( String name )
    {
        if( !m_useJAAS )
        {
            return new UnresolvedPrincipal(name);
        }

        // Check built-in Roles first
        Role role = new Role(name);
        if ( Role.isBuiltInRole( role ) )
        {
            return role;
        }

        // Check Authorizer Roles
        Principal principal = m_authorizer.findRole( name );
        if ( principal != null )
        {
            return principal;
        }

        // Check Groups
        principal = m_engine.getGroupManager().findRole( name );
        if ( principal != null )
        {
            return principal;
        }

        // Ok, no luck---this must be a user principal
        Principal[] principals = null;
        UserProfile profile = null;
        UserDatabase db = m_engine.getUserManager().getUserDatabase();
        try
        {
            profile = db.find( name );
            principals = db.getPrincipals( profile.getLoginName() );
            for (int i = 0; i < principals.length; i++)
            {
                principal = principals[i];
                if ( principal.getName().equals( name ) )
                {
                    return principal;
                }
            }
        }
        catch( NoSuchPrincipalException e )
        {
            // We couldn't find the user...
        }
        // Ok, no luck---mark this as unresolved and move on
        return new UnresolvedPrincipal( name );
    }
View Full Code Here

Examples of org.apache.wiki.auth.acl.UnresolvedPrincipal

        // We shouldn't be able to spoof a built-in role
        assertNotSame( new WikiPrincipal( "Authenticated" ), m_auth.resolvePrincipal( "Authenticated" ) );

        // An unknown user should resolve to a generic UnresolvedPrincipal
        Principal principal = new UnresolvedPrincipal( "Bart Simpson" );
        assertEquals( principal, m_auth.resolvePrincipal( "Bart Simpson" ) );
    }
View Full Code Here

Examples of org.apache.wiki.auth.acl.UnresolvedPrincipal

                    // Only use non-null/non-blank approvers
                    String approver = props.getProperty( prop );
                    if ( approver != null && approver.length() > 0 )
                    {
                        m_approvers.put( key, new UnresolvedPrincipal( approver ) );
                    }
                }
            }
        }
    }
View Full Code Here

Examples of org.apache.wiki.auth.acl.UnresolvedPrincipal

     */
    public final Principal resolvePrincipal( String name )
    {
        if( !m_useJAAS )
        {
            return new UnresolvedPrincipal(name);
        }

        // Check built-in Roles first
        Role role = new Role(name);
        if ( Role.isBuiltInRole( role ) )
        {
            return role;
        }

        // Check Authorizer Roles
        Principal principal = m_authorizer.findRole( name );
        if ( principal != null )
        {
            return principal;
        }

        // Check Groups
        principal = m_engine.getGroupManager().findRole( name );
        if ( principal != null )
        {
            return principal;
        }

        // Ok, no luck---this must be a user principal
        Principal[] principals = null;
        UserProfile profile = null;
        UserDatabase db = m_engine.getUserManager().getUserDatabase();
        try
        {
            profile = db.find( name );
            principals = db.getPrincipals( profile.getLoginName() );
            for (int i = 0; i < principals.length; i++)
            {
                principal = principals[i];
                if ( principal.getName().equals( name ) )
                {
                    return principal;
                }
            }
        }
        catch( NoSuchPrincipalException e )
        {
            // We couldn't find the user...
        }
        // Ok, no luck---mark this as unresolved and move on
        return new UnresolvedPrincipal( name );
    }
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.