Package org.apache.cassandra.exceptions

Examples of org.apache.cassandra.exceptions.UnauthorizedException


    }

    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 and not anonymous to perform this request");
    }
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.username,
                                                      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

    {
        if (perms.contains(Permission.FULL_ACCESS))
            return; // full access

        if (perms.contains(Permission.NO_ACCESS))
            throw new UnauthorizedException(String.format("%s does not have permission %s for %s",
                                                          user,
                                                          perm,
                                                          Resources.toString(resource)));


        boolean granular = false;

        for (Permission p : perms)
        {
            // mixing of old and granular permissions is denied by IAuthorityContainer
            // and CQL grammar so it's name to assume that once a granular permission is found
            // all other permissions are going to be a subset of Permission.GRANULAR_PERMISSIONS
            if (Permission.GRANULAR_PERMISSIONS.contains(p))
            {
                granular = true;
                break;
            }
        }

        if (granular)
        {
            if (perms.contains(perm))
                return; // user has a given permission, perm is always one of Permission.GRANULAR_PERMISSIONS
        }
        else
        {
            for (Permission p : perms)
            {
                if (Permission.oldToNew.get(p).contains(perm))
                    return;
            }
        }

        throw new UnauthorizedException(String.format("%s does not have permission %s for %s",
                                                      user,
                                                      perm,
                                                      Resources.toString(resource)));
    }
View Full Code Here

    {
        if (perms.contains(Permission.FULL_ACCESS))
            return; // full access

        if (perms.contains(Permission.NO_ACCESS))
            throw new UnauthorizedException(String.format("%s does not have permission %s for %s",
                                                          user,
                                                          perm,
                                                          Resources.toString(resource)));


        boolean granular = false;

        for (Permission p : perms)
        {
            // mixing of old and granular permissions is denied by IAuthorityContainer
            // and CQL grammar so it's name to assume that once a granular permission is found
            // all other permissions are going to be a subset of Permission.GRANULAR_PERMISSIONS
            if (Permission.GRANULAR_PERMISSIONS.contains(p))
            {
                granular = true;
                break;
            }
        }

        if (granular)
        {
            if (perms.contains(perm))
                return; // user has a given permission, perm is always one of Permission.GRANULAR_PERMISSIONS
        }
        else
        {
            for (Permission p : perms)
            {
                if (Permission.oldToNew.get(p).contains(perm))
                    return;
            }
        }

        throw new UnauthorizedException(String.format("%s does not have permission %s for %s",
                                                      user,
                                                      perm,
                                                      Resources.toString(resource)));
    }
View Full Code Here

        validateLogin();
        preventSystemKSSchemaModification(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 preventSystemKSSchemaModification(String keyspace, Permission perm) throws UnauthorizedException
    {
        if (Schema.systemKeyspaceNames.contains(keyspace.toLowerCase()) && !(perm.equals(Permission.SELECT) || perm.equals(Permission.MODIFY)))
            throw new UnauthorizedException(keyspace + " keyspace is not user-modifiable.");
    }
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.