Examples of UnresolvedPrincipal


Examples of com.ecyrd.jspwiki.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 com.ecyrd.jspwiki.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 com.ecyrd.jspwiki.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.harmony.security.UnresolvedPrincipal

     * otherwise tested set must contain all Principals of PolicyEntry.
     */
    public void testImpliesPrincipals() {
        PolicyEntry pe = new PolicyEntry(null, null, null);
        Principal[] pp1 = new Principal[] {};
        Principal[] pp2 = new Principal[] { new UnresolvedPrincipal("a.b.c",
            "XXX") };
        Principal[] pp3 = new Principal[] {
            new UnresolvedPrincipal("a.b.c", "YYY"),
            new UnresolvedPrincipal("a.b.c", "XXX"),
            new UnresolvedPrincipal("e.f.g", "ZZZ") };

        assertTrue(pe.impliesPrincipals(null));
        assertTrue(pe.impliesPrincipals(pp1));

        pe = new PolicyEntry(null, new HashSet(), null);
View Full Code Here

Examples of org.apache.harmony.security.UnresolvedPrincipal

                    pe.name = PolicyUtils.expand(pe.name, system);
                }
                if (pe.klass == null) {
                    principals.add(getPrincipalByAlias(ks, pe.name));
                } else {
                    principals.add(new UnresolvedPrincipal(pe.klass, pe.name));
                }
            }
        }
        if (ge.permissions != null) {
            for (Iterator<PermissionEntry> iter = ge.permissions.iterator(); iter.hasNext();) {
View Full Code Here

Examples of org.apache.harmony.security.UnresolvedPrincipal

                    pe.name = PolicyUtils.expand(pe.name, system);
                }
                if (pe.klass == null) {
                    principals.add(getPrincipalByAlias(ks, pe.name));
                } else {
                    principals.add(new UnresolvedPrincipal(pe.klass, pe.name));
                }
            }
        }
        if (ge.permissions != null) {
            for (Iterator<PermissionEntry> iter = ge.permissions.iterator(); iter.hasNext();) {
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.harmony.security.UnresolvedPrincipal

    }

    public void testCtor() {
        String klass = "abc";
        String name = "NAME";
        UnresolvedPrincipal up = new UnresolvedPrincipal(klass, name);
        assertEquals(klass, up.getClassName());
        assertEquals(name, up.getName());

        up = new UnresolvedPrincipal(klass, null);
        assertEquals(klass, up.getClassName());
        assertNull(up.getName());

        try {
            up = new UnresolvedPrincipal(null, name);
            fail("No IllegalArgumentException is thrown");
        } catch (IllegalArgumentException ok) {
        }
    }
View Full Code Here

Examples of org.apache.harmony.security.UnresolvedPrincipal

    public void testEquals_Principal() {
        String name = "sgrt";
        FakePrincipal fp = new FakePrincipal(name);

        assertTrue(new UnresolvedPrincipal(FakePrincipal.class.getName(), name)
            .equals(fp));
        assertTrue(new UnresolvedPrincipal(UnresolvedPrincipal.WILDCARD, name)
            .equals(fp));
        assertTrue(new UnresolvedPrincipal(FakePrincipal.class.getName(),
            UnresolvedPrincipal.WILDCARD).equals(fp));

        assertFalse(new UnresolvedPrincipal(FakePrincipal.class.getName(),
            "sdkljfgbkwe").equals(fp));
    }
View Full Code Here

Examples of org.apache.harmony.security.UnresolvedPrincipal

    }

    public void testEquals_Common() {
        String klass = "abc";
        String name = "NAME";
        UnresolvedPrincipal up = new UnresolvedPrincipal(klass, name);
        UnresolvedPrincipal up2 = new UnresolvedPrincipal(klass, name);
        UnresolvedPrincipal up3 = new UnresolvedPrincipal(name, klass);

        assertTrue(up.equals(up));
        assertTrue(up.equals(up2));
        assertEquals(up.hashCode(), up2.hashCode());
        assertFalse(up.equals(up3));
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.