Search in sources :

Example 16 with ThriftSecurityException

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

the class SecurityOperation method grantSystemPermission.

public void grantSystemPermission(TCredentials credentials, String user, SystemPermission permissionById) throws ThriftSecurityException {
    if (!canGrantSystem(credentials, user, permissionById))
        throw new ThriftSecurityException(credentials.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
    targetUserExists(user);
    try {
        permHandle.grantSystemPermission(user, permissionById);
        log.info("Granted system permission {} for user {} at the request of user {}", permissionById, user, credentials.getPrincipal());
    } catch (AccumuloSecurityException e) {
        throw e.asThriftException();
    }
}
Also used : AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException)

Example 17 with ThriftSecurityException

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

the class SecurityOperation method revokeTablePermission.

public void revokeTablePermission(TCredentials c, String user, Table.ID tableId, TablePermission permission, Namespace.ID namespaceId) throws ThriftSecurityException {
    if (!canRevokeTable(c, user, tableId, namespaceId))
        throw new ThriftSecurityException(c.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
    targetUserExists(user);
    try {
        permHandle.revokeTablePermission(user, tableId.canonicalID(), 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.client.impl.thrift.ThriftSecurityException)

Example 18 with ThriftSecurityException

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

the class SecurityOperation method grantTablePermission.

public void grantTablePermission(TCredentials c, String user, Table.ID tableId, TablePermission permission, Namespace.ID namespaceId) throws ThriftSecurityException {
    if (!canGrantTable(c, user, tableId, namespaceId))
        throw new ThriftSecurityException(c.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
    targetUserExists(user);
    try {
        permHandle.grantTablePermission(user, tableId.canonicalID(), permission);
        log.info("Granted 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.client.impl.thrift.ThriftSecurityException)

Example 19 with ThriftSecurityException

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

the class AuditedSecurityOperation method canScan.

@Override
public boolean canScan(TCredentials credentials, Table.ID tableId, Namespace.ID namespaceId, TRange range, List<TColumn> columns, List<IterInfo> ssiList, Map<String, Map<String, String>> ssio, List<ByteBuffer> authorizations) throws ThriftSecurityException {
    if (shouldAudit(credentials, tableId)) {
        Range convertedRange = new Range(range);
        List<String> convertedColumns = truncate(Translator.translate(columns, new Translator.TColumnTranslator()));
        String tableName = getTableName(tableId);
        try {
            boolean canScan = super.canScan(credentials, tableId, namespaceId);
            audit(credentials, canScan, CAN_SCAN_AUDIT_TEMPLATE, tableName, getAuthString(authorizations), convertedRange, convertedColumns, ssiList, ssio);
            return canScan;
        } catch (ThriftSecurityException ex) {
            audit(credentials, ex, CAN_SCAN_AUDIT_TEMPLATE, getAuthString(authorizations), tableId, convertedRange, convertedColumns, ssiList, ssio);
            throw ex;
        }
    } else {
        return super.canScan(credentials, tableId, namespaceId);
    }
}
Also used : TRange(org.apache.accumulo.core.data.thrift.TRange) Range(org.apache.accumulo.core.data.Range) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException)

Example 20 with ThriftSecurityException

use of org.apache.accumulo.core.client.impl.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.client.impl.thrift.ThriftSecurityException)

Aggregations

ThriftSecurityException (org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException)45 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)38 AccumuloException (org.apache.accumulo.core.client.AccumuloException)23 TException (org.apache.thrift.TException)23 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)22 ThriftTableOperationException (org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException)16 NamespaceNotFoundException (org.apache.accumulo.core.client.NamespaceNotFoundException)12 IOException (java.io.IOException)11 ArrayList (java.util.ArrayList)10 TTransportException (org.apache.thrift.transport.TTransportException)10 TabletClientService (org.apache.accumulo.core.tabletserver.thrift.TabletClientService)8 Namespace (org.apache.accumulo.core.client.impl.Namespace)6 Table (org.apache.accumulo.core.client.impl.Table)6 ThriftNotActiveServiceException (org.apache.accumulo.core.client.impl.thrift.ThriftNotActiveServiceException)6 MasterClientService (org.apache.accumulo.core.master.thrift.MasterClientService)6 HostAndPort (org.apache.accumulo.core.util.HostAndPort)6 Key (org.apache.accumulo.core.data.Key)5 Range (org.apache.accumulo.core.data.Range)5 KeyExtent (org.apache.accumulo.core.data.impl.KeyExtent)5 TApplicationException (org.apache.thrift.TApplicationException)5