当前位置: 首页>>代码示例>>Java>>正文


Java UnauthorizedException类代码示例

本文整理汇总了Java中org.apache.cassandra.exceptions.UnauthorizedException的典型用法代码示例。如果您正苦于以下问题:Java UnauthorizedException类的具体用法?Java UnauthorizedException怎么用?Java UnauthorizedException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UnauthorizedException类属于org.apache.cassandra.exceptions包,在下文中一共展示了UnauthorizedException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkAccess

import org.apache.cassandra.exceptions.UnauthorizedException; //导入依赖的package包/类
public void checkAccess(ClientState state) throws UnauthorizedException
{
    AuthenticatedUser user = state.getUser();

    boolean isSuper = user.isSuper();

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

    if (superuser != null && !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 (!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));
        }
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:25,代码来源:AlterUserStatement.java

示例2: prepareRowMutations

import org.apache.cassandra.exceptions.UnauthorizedException; //导入依赖的package包/类
public List<IMutation> prepareRowMutations(String keyspace, ThriftClientState clientState, Long timestamp, List<ByteBuffer> variables)
throws InvalidRequestException, UnauthorizedException
{
    CFMetaData metadata = validateColumnFamily(keyspace, columnFamily);

    clientState.hasColumnFamilyAccess(keyspace, columnFamily, Permission.MODIFY);
    AbstractType<?> keyType = Schema.instance.getCFMetaData(keyspace, columnFamily).getKeyValidator();

    List<IMutation> rowMutations = new ArrayList<IMutation>(keys.size());

    for (Term key : keys)
    {
        rowMutations.add(mutationForKey(key.getByteBuffer(keyType, variables), keyspace, timestamp, clientState, variables, metadata));
    }

    return rowMutations;
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:18,代码来源:DeleteStatement.java

示例3: checkAccess

import org.apache.cassandra.exceptions.UnauthorizedException; //导入依赖的package包/类
public void checkAccess(ClientState state) throws UnauthorizedException, InvalidRequestException
{
    Function function = findFunction();
    if (function == null)
    {
        if (!ifExists)
            throw new InvalidRequestException(String.format("Unconfigured function %s.%s(%s)",
                                                            functionName.keyspace,
                                                            functionName.name,
                                                            Joiner.on(",").join(argRawTypes)));
    }
    else
    {
        state.ensureHasPermission(Permission.DROP, FunctionResource.function(function.name().keyspace,
                                                                             function.name().name,
                                                                             function.argTypes()));
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:19,代码来源:DropFunctionStatement.java

示例4: preventSystemKSSchemaModification

import org.apache.cassandra.exceptions.UnauthorizedException; //导入依赖的package包/类
private void preventSystemKSSchemaModification(String keyspace, DataResource resource, Permission perm) throws UnauthorizedException
{
    // we only care about schema modification.
    if (!((perm == Permission.ALTER) || (perm == Permission.DROP) || (perm == Permission.CREATE)))
        return;

    // prevent system keyspace modification
    if (Schema.isSystemKeyspace(keyspace))
        throw new UnauthorizedException(keyspace + " keyspace is not user-modifiable.");

    // allow users with sufficient privileges to alter KS level options on AUTH_KS and
    // TRACING_KS, and also to drop legacy tables (users, credentials, permissions) from
    // AUTH_KS
    if (ALTERABLE_SYSTEM_KEYSPACES.contains(resource.getKeyspace().toLowerCase())
       && ((perm == Permission.ALTER && !resource.isKeyspaceLevel())
           || (perm == Permission.DROP && !DROPPABLE_SYSTEM_TABLES.contains(resource))))
    {
        throw new UnauthorizedException(String.format("Cannot %s %s", perm, resource));
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:21,代码来源:ClientState.java

示例5: checkAccess

import org.apache.cassandra.exceptions.UnauthorizedException; //导入依赖的package包/类
public void checkAccess(ClientState state) throws UnauthorizedException, InvalidRequestException
{
    try
    {
        state.hasColumnFamilyAccess(keyspace(), columnFamily(), Permission.DROP);
    }
    catch (InvalidRequestException e)
    {
        if (!ifExists)
            throw e;
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:13,代码来源:DropTableStatement.java

示例6: checkAccess

import org.apache.cassandra.exceptions.UnauthorizedException; //导入依赖的package包/类
public void checkAccess(ClientState state) throws UnauthorizedException
{
    // check that the user has AUTHORIZE permission on the resource or its parents, otherwise reject GRANT/REVOKE.
    state.ensureHasPermission(Permission.AUTHORIZE, resource);
    // check that the user has [a single permission or all in case of ALL] on the resource or its parents.
    for (Permission p : permissions)
        state.ensureHasPermission(p, resource);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:9,代码来源:PermissionAlteringStatement.java

示例7: prepareRowMutations

import org.apache.cassandra.exceptions.UnauthorizedException; //导入依赖的package包/类
/** {@inheritDoc} */
public List<IMutation> prepareRowMutations(String keyspace, ThriftClientState clientState, Long timestamp, List<ByteBuffer> variables)
throws InvalidRequestException, UnauthorizedException
{
    boolean hasCommutativeOperation = false;

    for (Map.Entry<Term, Operation> column : getColumns().entrySet())
    {
        if (!column.getValue().isUnary())
            hasCommutativeOperation = true;

        if (hasCommutativeOperation && column.getValue().isUnary())
            throw new InvalidRequestException("Mix of commutative and non-commutative operations is not allowed.");
    }

    CFMetaData metadata = validateColumnFamily(keyspace, columnFamily, hasCommutativeOperation);
    if (hasCommutativeOperation)
        getConsistencyLevel().validateCounterForWrite(metadata);

    QueryProcessor.validateKeyAlias(metadata, keyName);

    clientState.hasColumnFamilyAccess(keyspace, columnFamily, Permission.MODIFY);

    List<IMutation> mutations = new LinkedList<>();

    for (Term key: keys)
        mutations.add(mutationForKey(keyspace, key.getByteBuffer(getKeyType(keyspace),variables), metadata, timestamp, clientState, variables));

    return mutations;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:31,代码来源:UpdateStatement.java

示例8: getMutations

import org.apache.cassandra.exceptions.UnauthorizedException; //导入依赖的package包/类
public List<IMutation> getMutations(String keyspace, ThriftClientState clientState, List<ByteBuffer> variables)
throws InvalidRequestException, UnauthorizedException
{
    List<IMutation> batch = new LinkedList<IMutation>();

    for (AbstractModification statement : statements) {
        batch.addAll(statement.prepareRowMutations(keyspace, clientState, timestamp, variables));
    }

    return batch;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:12,代码来源:BatchStatement.java

示例9: prepareRowMutations

import org.apache.cassandra.exceptions.UnauthorizedException; //导入依赖的package包/类
public List<IMutation> prepareRowMutations(String keyspace, ThriftClientState clientState, Long timestamp, List<ByteBuffer> variables)
throws InvalidRequestException, UnauthorizedException
{
    CFMetaData metadata = validateColumnFamily(keyspace, columnFamily);

    clientState.hasColumnFamilyAccess(keyspace, columnFamily, Permission.MODIFY);
    AbstractType<?> keyType = Schema.instance.getCFMetaData(keyspace, columnFamily).getKeyValidator();

    List<IMutation> mutations = new ArrayList<IMutation>(keys.size());

    for (Term key : keys)
        mutations.add(mutationForKey(key.getByteBuffer(keyType, variables), keyspace, timestamp, clientState, variables, metadata));

    return mutations;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:16,代码来源:DeleteStatement.java

示例10: hasAllKeyspacesAccess

import org.apache.cassandra.exceptions.UnauthorizedException; //导入依赖的package包/类
public void hasAllKeyspacesAccess(Permission perm) throws UnauthorizedException
{
    if (isInternal)
        return;
    validateLogin();
    ensureHasPermission(perm, DataResource.root());
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:8,代码来源:ClientState.java

示例11: hasAccess

import org.apache.cassandra.exceptions.UnauthorizedException; //导入依赖的package包/类
private void hasAccess(String keyspace, Permission perm, DataResource resource)
throws UnauthorizedException, InvalidRequestException
{
    validateKeyspace(keyspace);
    if (isInternal)
        return;
    validateLogin();
    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);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:16,代码来源:ClientState.java

示例12: ensureHasPermission

import org.apache.cassandra.exceptions.UnauthorizedException; //导入依赖的package包/类
public void ensureHasPermission(Permission perm, IResource resource) throws UnauthorizedException
{
    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));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:12,代码来源:ClientState.java

示例13: preventSystemKSSchemaModification

import org.apache.cassandra.exceptions.UnauthorizedException; //导入依赖的package包/类
private void preventSystemKSSchemaModification(String keyspace, DataResource resource, Permission perm) throws UnauthorizedException
{
    // we only care about schema modification.
    if (!(perm.equals(Permission.ALTER) || perm.equals(Permission.DROP) || perm.equals(Permission.CREATE)))
        return;

    // prevent system keyspace modification
    if (Keyspace.SYSTEM_KS.equalsIgnoreCase(keyspace))
        throw new UnauthorizedException(keyspace + " keyspace is not user-modifiable.");

    // we want to allow altering AUTH_KS and TRACING_KS.
    Set<String> allowAlter = Sets.newHashSet(Auth.AUTH_KS, Tracing.TRACE_KS);
    if (allowAlter.contains(keyspace.toLowerCase()) && !(resource.isKeyspaceLevel() && perm.equals(Permission.ALTER)))
        throw new UnauthorizedException(String.format("Cannot %s %s", perm, resource));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:16,代码来源:ClientState.java

示例14: prepareRowMutations

import org.apache.cassandra.exceptions.UnauthorizedException; //导入依赖的package包/类
/** {@inheritDoc} */
public List<IMutation> prepareRowMutations(String keyspace, ThriftClientState clientState, Long timestamp, List<ByteBuffer> variables)
throws InvalidRequestException, UnauthorizedException
{
    boolean hasCommutativeOperation = false;

    for (Map.Entry<Term, Operation> column : getColumns().entrySet())
    {
        if (!column.getValue().isUnary())
            hasCommutativeOperation = true;

        if (hasCommutativeOperation && column.getValue().isUnary())
            throw new InvalidRequestException("Mix of commutative and non-commutative operations is not allowed.");
    }

    CFMetaData metadata = validateColumnFamily(keyspace, columnFamily, hasCommutativeOperation);
    if (hasCommutativeOperation)
        getConsistencyLevel().validateCounterForWrite(metadata);

    QueryProcessor.validateKeyAlias(metadata, keyName);

    clientState.hasColumnFamilyAccess(keyspace, columnFamily, Permission.MODIFY);

    List<IMutation> rowMutations = new LinkedList<IMutation>();

    for (Term key: keys)
    {
        rowMutations.add(mutationForKey(keyspace, key.getByteBuffer(getKeyType(keyspace),variables), metadata, timestamp, clientState, variables));
    }

    return rowMutations;
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:33,代码来源:UpdateStatement.java

示例15: preventSystemKSSchemaModification

import org.apache.cassandra.exceptions.UnauthorizedException; //导入依赖的package包/类
private void preventSystemKSSchemaModification(String keyspace, DataResource resource, Permission perm) throws UnauthorizedException
{
    // we only care about schema modification.
    if (!(perm.equals(Permission.ALTER) || perm.equals(Permission.DROP) || perm.equals(Permission.CREATE)))
        return;

    if (Schema.systemKeyspaceNames.contains(keyspace.toLowerCase()))
        throw new UnauthorizedException(keyspace + " keyspace is not user-modifiable.");

    // we want to allow altering AUTH_KS itself.
    if (keyspace.equals(Auth.AUTH_KS) && !(resource.isKeyspaceLevel() && perm.equals(Permission.ALTER)))
        throw new UnauthorizedException(String.format("Cannot %s %s", perm, resource));
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:14,代码来源:ClientState.java


注:本文中的org.apache.cassandra.exceptions.UnauthorizedException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。