Search in sources :

Example 36 with ThriftSecurityException

use of org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException in project accumulo by apache.

the class SecurityOperation method changePassword.

public void changePassword(TCredentials credentials, Credentials toChange) throws ThriftSecurityException {
    if (!canChangePassword(credentials, toChange.getPrincipal()))
        throw new ThriftSecurityException(credentials.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
    try {
        AuthenticationToken token = toChange.getToken();
        authenticator.changePassword(toChange.getPrincipal(), token);
        log.info("Changed password for user {} at the request of user {}", toChange.getPrincipal(), credentials.getPrincipal());
    } catch (AccumuloSecurityException e) {
        throw e.asThriftException();
    }
}
Also used : AuthenticationToken(org.apache.accumulo.core.client.security.tokens.AuthenticationToken) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException)

Example 37 with ThriftSecurityException

use of org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException in project accumulo by apache.

the class SecurityOperation method getUserAuthorizations.

public Authorizations getUserAuthorizations(TCredentials credentials, String user) throws ThriftSecurityException {
    authenticate(credentials);
    targetUserExists(user);
    if (!credentials.getPrincipal().equals(user) && !hasSystemPermission(credentials, SystemPermission.SYSTEM, false) && !hasSystemPermission(credentials, SystemPermission.ALTER_USER, false))
        throw new ThriftSecurityException(credentials.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
    return authorizor.getCachedUserAuthorizations(user);
}
Also used : ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException)

Example 38 with ThriftSecurityException

use of org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException in project accumulo by apache.

the class SecurityOperation method dropUser.

public void dropUser(TCredentials credentials, String user) throws ThriftSecurityException {
    if (!canDropUser(credentials, user))
        throw new ThriftSecurityException(credentials.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
    try {
        authorizor.dropUser(user);
        authenticator.dropUser(user);
        permHandle.cleanUser(user);
        log.info("Deleted user {} at the request of user {}", user, credentials.getPrincipal());
    } catch (AccumuloSecurityException e) {
        throw e.asThriftException();
    }
}
Also used : AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException)

Example 39 with ThriftSecurityException

use of org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException in project accumulo by apache.

the class SecurityOperation method revokeTablePermission.

public void revokeTablePermission(TCredentials c, String user, TableId tableId, TablePermission permission, NamespaceId namespaceId) throws ThriftSecurityException {
    if (!canRevokeTable(c, user, tableId, namespaceId))
        throw new ThriftSecurityException(c.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
    targetUserExists(user);
    try {
        permHandle.revokeTablePermission(user, tableId.canonical(), permission);
        log.info("Revoked table permission {} for user {} on the table {} at the request of user {}", permission, user, tableId, c.getPrincipal());
    } catch (AccumuloSecurityException e) {
        throw e.asThriftException();
    } catch (TableNotFoundException e) {
        throw new ThriftSecurityException(c.getPrincipal(), SecurityErrorCode.TABLE_DOESNT_EXIST);
    }
}
Also used : TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException)

Example 40 with ThriftSecurityException

use of org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException in project accumulo by apache.

the class TableOperationsImpl method testClassLoad.

@Override
public boolean testClassLoad(final String tableName, final String className, final String asTypeName) throws TableNotFoundException, AccumuloException, AccumuloSecurityException {
    EXISTING_TABLE_NAME.validate(tableName);
    checkArgument(className != null, "className is null");
    checkArgument(asTypeName != null, "asTypeName is null");
    try {
        return ServerClient.executeRaw(context, client -> client.checkTableClass(TraceUtil.traceInfo(), context.rpcCreds(), tableName, className, asTypeName));
    } catch (ThriftTableOperationException e) {
        switch(e.getType()) {
            case NOTFOUND:
                throw new TableNotFoundException(e);
            case NAMESPACE_NOTFOUND:
                throw new TableNotFoundException(tableName, new NamespaceNotFoundException(e));
            default:
                throw new AccumuloException(e.description, e);
        }
    } catch (ThriftSecurityException e) {
        throw new AccumuloSecurityException(e.user, e.code, e);
    } catch (AccumuloException e) {
        throw e;
    } catch (Exception e) {
        throw new AccumuloException(e);
    }
}
Also used : TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) ThriftTableOperationException(org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) NamespaceNotFoundException(org.apache.accumulo.core.client.NamespaceNotFoundException) TableOfflineException(org.apache.accumulo.core.client.TableOfflineException) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) NamespaceNotFoundException(org.apache.accumulo.core.client.NamespaceNotFoundException) ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) TableExistsException(org.apache.accumulo.core.client.TableExistsException) TException(org.apache.thrift.TException) IOException(java.io.IOException) TTransportException(org.apache.thrift.transport.TTransportException) NamespaceExistsException(org.apache.accumulo.core.client.NamespaceExistsException) FileNotFoundException(java.io.FileNotFoundException) ThriftNotActiveServiceException(org.apache.accumulo.core.clientImpl.thrift.ThriftNotActiveServiceException) NotServingTabletException(org.apache.accumulo.core.tabletserver.thrift.NotServingTabletException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) TApplicationException(org.apache.thrift.TApplicationException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) ThriftTableOperationException(org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException)

Aggregations

ThriftSecurityException (org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException)61 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)33 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)28 TException (org.apache.thrift.TException)25 ThriftTableOperationException (org.apache.accumulo.core.clientImpl.thrift.ThriftTableOperationException)20 IOException (java.io.IOException)19 ArrayList (java.util.ArrayList)14 AccumuloException (org.apache.accumulo.core.client.AccumuloException)14 TableId (org.apache.accumulo.core.data.TableId)14 TKeyExtent (org.apache.accumulo.core.dataImpl.thrift.TKeyExtent)14 NamespaceNotFoundException (org.apache.accumulo.core.client.NamespaceNotFoundException)13 KeyExtent (org.apache.accumulo.core.dataImpl.KeyExtent)13 NamespaceId (org.apache.accumulo.core.data.NamespaceId)11 Tablet (org.apache.accumulo.tserver.tablet.Tablet)10 NoNodeException (org.apache.zookeeper.KeeperException.NoNodeException)10 HashSet (java.util.HashSet)9 NotServingTabletException (org.apache.accumulo.core.tabletserver.thrift.NotServingTabletException)9 TabletClientService (org.apache.accumulo.core.tabletserver.thrift.TabletClientService)9 HashMap (java.util.HashMap)8 Map (java.util.Map)8