Package org.apache.cassandra.exceptions

Examples of org.apache.cassandra.exceptions.UnauthorizedException


    {
        state.validateLogin();
        AuthenticatedUser user = state.getUser();

        if (superuser != null && user.getName().equals(username))
            throw new UnauthorizedException("You aren't allowed to alter your own superuser status");

        if (superuser != null && !user.isSuper())
            throw new UnauthorizedException("Only superusers are allowed to alter superuser status");

        if (!user.isSuper() && !user.getName().equals(username))
            throw new UnauthorizedException("You aren't allowed to alter this user");

        if (!user.isSuper())
        {
            for (IAuthenticator.Option option : opts.getOptions().keySet())
            {
                if (!DatabaseDescriptor.getAuthenticator().alterableOptions().contains(option))
                    throw new UnauthorizedException(String.format("You aren't allowed to alter %s option", option));
            }
        }
    }
View Full Code Here


    public void checkAccess(ClientState state) throws UnauthorizedException
    {
        state.validateLogin();

        if (!state.getUser().isSuper())
            throw new UnauthorizedException("Only superusers are allowed to perfrom CREATE USER queries");
    }
View Full Code Here

    public void checkAccess(ClientState state) throws UnauthorizedException
    {
        state.validateLogin();
        if (!state.getUser().isSuper())
            throw new UnauthorizedException("Only superusers are allowed to perfrom DROP USER queries");
    }
View Full Code Here

        validateLogin();
        preventSystemKSSModification(keyspace, perm);
        if (perm.equals(Permission.SELECT) && READABLE_SYSTEM_RESOURCES.contains(resource))
            return;
        if (PROTECTED_AUTH_RESOURCES.contains(resource))
            throw new UnauthorizedException(String.format("Resource %s is inaccessible", resource));
        ensureHasPermission(perm, resource);
    }
View Full Code Here

        for (IResource r : Resources.chain(resource))
        {
            if (authorize(r).contains(perm))
                return;
        }
        throw new UnauthorizedException(String.format("User %s has no %s permission on %s or any of its parents",
                                                      user.getName(),
                                                      perm,
                                                      resource));
    }
View Full Code Here

    }

    private void preventSystemKSSModification(String keyspace, Permission perm) throws UnauthorizedException
    {
        if (Schema.systemKeyspaceNames.contains(keyspace.toLowerCase()) && !perm.equals(Permission.SELECT))
            throw new UnauthorizedException(keyspace + " keyspace is not user-modifiable.");
    }
View Full Code Here

    }

    public void validateLogin() throws UnauthorizedException
    {
        if (user == null)
            throw new UnauthorizedException("You have not logged in");
    }
View Full Code Here

    public void ensureNotAnonymous() throws UnauthorizedException
    {
        validateLogin();
        if (user.isAnonymous())
            throw new UnauthorizedException("You have to be logged in to perform this query");
    }
View Full Code Here

        preventSystemKSSchemaModification(keyspace, resource, perm);
        if (perm.equals(Permission.SELECT) && READABLE_SYSTEM_RESOURCES.contains(resource))
            return;
        if (PROTECTED_AUTH_RESOURCES.contains(resource))
            if (perm.equals(Permission.CREATE) || perm.equals(Permission.ALTER) || perm.equals(Permission.DROP))
                throw new UnauthorizedException(String.format("%s schema is protected", resource));
        ensureHasPermission(perm, resource);
    }
View Full Code Here

    {
        for (IResource r : Resources.chain(resource))
            if (authorize(r).contains(perm))
                return;

        throw new UnauthorizedException(String.format("User %s has no %s permission on %s or any of its parents",
                                                      user.getName(),
                                                      perm,
                                                      resource));
    }
View Full Code Here

TOP

Related Classes of org.apache.cassandra.exceptions.UnauthorizedException

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.