Package org.apache.derby.authentication

Examples of org.apache.derby.authentication.DatabasePrincipal


     * Tests DatabasePrincipal.
     */
    private void checkDatabasePrincipal() throws IOException {
        // test DatabasePrincipal with null name argument
        try {
            new DatabasePrincipal(null);
            fail("expected NullPointerException");
        } catch (NullPointerException ex) {
            // expected exception
        }

        // test DatabasePrincipal with empty name argument
        try {
            new DatabasePrincipal("");
            fail("expected IllegalArgumentException");
        } catch (IllegalArgumentException ex) {
            // expected exception
        }
       
        // test DatabasePrincipal with illegal name argument
        try {
            new DatabasePrincipal("disallowed: unescaped *");
            fail("expected IllegalArgumentException");
        } catch (IllegalArgumentException ex) {
            // expected exception
        }

        // test DatabasePrincipal with illegal name argument
        try {
            new DatabasePrincipal("not yet supported: userName@databaseName");
            fail("expected IllegalArgumentException");
        } catch (IllegalArgumentException ex) {
            // expected exception
        }

        // test DatabasePrincipal with legal name argument
        new DatabasePrincipal("supported: userNameWith\\\\character");
        new DatabasePrincipal("supported: userNameWith\\*character");
        new DatabasePrincipal("supported: userNameWith\\@character");
        new DatabasePrincipal("*");
    }
View Full Code Here


        // test SystemPermission.implies()
        assertTrue(sp0.implies(sp1));
        assertTrue(sp1.implies(sp0));

        // test SystemPermission for authorized user against policy file
        final DatabasePrincipal authorizedUser
            = new DatabasePrincipal("authorizedSystemUser");
        execute(authorizedUser, new ShutdownEngineAction(sp0), true);
       
        // test SystemPermission for unauthorized user against policy file
        final DatabasePrincipal unAuthorizedUser
            = new DatabasePrincipal("unAuthorizedSystemUser");
        execute(unAuthorizedUser, new ShutdownEngineAction(sp0), false);
    }
View Full Code Here

        checkImplies(absDirPathPermissions,
                     absDirPathAliasPermissions);
       

        // test DatabasePermission for authorized user against policy file
        final DatabasePrincipal authorizedUser
            = new DatabasePrincipal("authorizedSystemUser");
        execute(authorizedUser,
                new CreateDatabaseAction(relDirPathPermissions[2]), true);
        execute(authorizedUser,
                new CreateDatabaseAction(relDirPathPermissions[3]), true);
        execute(authorizedUser,
                new CreateDatabaseAction(relDirPathPermissions[6]), false);
        execute(authorizedUser,
                new CreateDatabaseAction(relDirPathPermissions[7]), true);

        // test DatabasePermission for unauthorized user against policy file
        final DatabasePrincipal unAuthorizedUser
            = new DatabasePrincipal("unAuthorizedSystemUser");
        execute(unAuthorizedUser,
                new CreateDatabaseAction(relDirPathPermissions[2]), false);
        execute(unAuthorizedUser,
                new CreateDatabaseAction(relDirPathPermissions[3]), false);
        execute(unAuthorizedUser,
                new CreateDatabaseAction(relDirPathPermissions[6]), false);
        execute(unAuthorizedUser,
                new CreateDatabaseAction(relDirPathPermissions[7]), false);

        // test DatabasePermission for authorized user against policy file
        final DatabasePrincipal anyUser
            = new DatabasePrincipal("anyUser");
        final DatabasePermission dbPerm
            = new DatabasePermission("directory:dir",
                                     DatabasePermission.CREATE);
        execute(anyUser,
                new CreateDatabaseAction(dbPerm), true);
View Full Code Here

     * Tests DatabasePrincipal.
     */
    private void checkDatabasePrincipal() throws IOException {
        // test DatabasePrincipal with null name argument
        try {
            new DatabasePrincipal(null);
            fail("expected NullPointerException");
        } catch (NullPointerException ex) {
            // expected exception
        }

        // test DatabasePrincipal with empty name argument
        try {
            new DatabasePrincipal("");
            fail("expected IllegalArgumentException");
        } catch (IllegalArgumentException ex) {
            // expected exception
        }
       
        // test DatabasePrincipal with illegal name argument
        try {
            new DatabasePrincipal("disallowed: unescaped *");
            fail("expected IllegalArgumentException");
        } catch (IllegalArgumentException ex) {
            // expected exception
        }

        // test DatabasePrincipal with illegal name argument
        try {
            new DatabasePrincipal("not yet supported: userName@databaseName");
            fail("expected IllegalArgumentException");
        } catch (IllegalArgumentException ex) {
            // expected exception
        }

        // test DatabasePrincipal with legal name argument
        new DatabasePrincipal("supported: userNameWith\\\\character");
        new DatabasePrincipal("supported: userNameWith\\*character");
        new DatabasePrincipal("supported: userNameWith\\@character");
        new DatabasePrincipal("*");
    }
View Full Code Here

        // test SystemPermission.implies()
        assertTrue(sp0.implies(sp1));
        assertTrue(sp1.implies(sp0));

        // test SystemPermission for authorized user against policy file
        final DatabasePrincipal authorizedUser
            = new DatabasePrincipal("authorizedSystemUser");
        execute(authorizedUser, new ShutdownEngineAction(sp0), true);
       
        // test SystemPermission for unauthorized user against policy file
        final DatabasePrincipal unAuthorizedUser
            = new DatabasePrincipal("unAuthorizedSystemUser");
        execute(unAuthorizedUser, new ShutdownEngineAction(sp0), false);
    }
View Full Code Here

        checkImplies(absDirPathPermissions,
                     absDirPathAliasPermissions);
       

        // test DatabasePermission for authorized user against policy file
        final DatabasePrincipal authorizedUser
            = new DatabasePrincipal("authorizedSystemUser");
        execute(authorizedUser,
                new CreateDatabaseAction(relDirPathPermissions[2]), true);
        execute(authorizedUser,
                new CreateDatabaseAction(relDirPathPermissions[3]), true);
        execute(authorizedUser,
                new CreateDatabaseAction(relDirPathPermissions[6]), false);
        execute(authorizedUser,
                new CreateDatabaseAction(relDirPathPermissions[7]), true);

        // test DatabasePermission for unauthorized user against policy file
        final DatabasePrincipal unAuthorizedUser
            = new DatabasePrincipal("unAuthorizedSystemUser");
        execute(unAuthorizedUser,
                new CreateDatabaseAction(relDirPathPermissions[2]), false);
        execute(unAuthorizedUser,
                new CreateDatabaseAction(relDirPathPermissions[3]), false);
        execute(unAuthorizedUser,
                new CreateDatabaseAction(relDirPathPermissions[6]), false);
        execute(unAuthorizedUser,
                new CreateDatabaseAction(relDirPathPermissions[7]), false);

        // test DatabasePermission for authorized user against policy file
        final DatabasePrincipal anyUser
            = new DatabasePrincipal("anyUser");
        final DatabasePermission dbPerm
            = new DatabasePermission("directory:dir",
                                     DatabasePermission.CREATE);
        execute(anyUser,
                new CreateDatabaseAction(dbPerm), true);
View Full Code Here

TOP

Related Classes of org.apache.derby.authentication.DatabasePrincipal

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.