Search in sources :

Example 6 with Credentials

use of org.apache.accumulo.core.clientImpl.Credentials in project accumulo by apache.

the class ManagerApiIT method setup.

@BeforeClass
public static void setup() throws Exception {
    // need to pretend to be a server, so we can bypass all of
    // the singleton resource management in this test
    SingletonManager.setMode(Mode.SERVER);
    SharedMiniClusterBase.startMiniCluster();
    rootUser = new Credentials(getPrincipal(), getToken());
    regularUser = new Credentials("regularUser", new PasswordToken("regularUser"));
    privilegedUser = new Credentials("privilegedUser", new PasswordToken("privilegedUser"));
    try (AccumuloClient client = Accumulo.newClient().from(getClientProps()).build()) {
        SecurityOperations rootSecOps = client.securityOperations();
        for (Credentials user : Arrays.asList(regularUser, privilegedUser)) rootSecOps.createLocalUser(user.getPrincipal(), (PasswordToken) user.getToken());
        rootSecOps.grantSystemPermission(privilegedUser.getPrincipal(), SystemPermission.SYSTEM);
    }
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) SecurityOperations(org.apache.accumulo.core.client.admin.SecurityOperations) TCredentials(org.apache.accumulo.core.securityImpl.thrift.TCredentials) Credentials(org.apache.accumulo.core.clientImpl.Credentials) BeforeClass(org.junit.BeforeClass)

Example 7 with Credentials

use of org.apache.accumulo.core.clientImpl.Credentials in project accumulo by apache.

the class MetadataTableUtil method getRootTable.

public static synchronized Writer getRootTable(ServerContext context) {
    Credentials credentials = context.getCredentials();
    Writer rootTable = root_tables.get(credentials);
    if (rootTable == null) {
        rootTable = new Writer(context, RootTable.ID);
        root_tables.put(credentials, rootTable);
    }
    return rootTable;
}
Also used : Credentials(org.apache.accumulo.core.clientImpl.Credentials) Writer(org.apache.accumulo.core.clientImpl.Writer) BatchWriter(org.apache.accumulo.core.client.BatchWriter)

Example 8 with Credentials

use of org.apache.accumulo.core.clientImpl.Credentials in project accumulo by apache.

the class MetadataTableUtil method getMetadataTable.

public static synchronized Writer getMetadataTable(ServerContext context) {
    Credentials credentials = context.getCredentials();
    Writer metadataTable = metadata_tables.get(credentials);
    if (metadataTable == null) {
        metadataTable = new Writer(context, MetadataTable.ID);
        metadata_tables.put(credentials, metadataTable);
    }
    return metadataTable;
}
Also used : Credentials(org.apache.accumulo.core.clientImpl.Credentials) Writer(org.apache.accumulo.core.clientImpl.Writer) BatchWriter(org.apache.accumulo.core.client.BatchWriter)

Example 9 with Credentials

use of org.apache.accumulo.core.clientImpl.Credentials in project accumulo by apache.

the class ClientServiceHandler method changeLocalUserPassword.

@Override
public void changeLocalUserPassword(TInfo tinfo, TCredentials credentials, String principal, ByteBuffer password) throws ThriftSecurityException {
    PasswordToken token = new PasswordToken(password);
    Credentials toChange = new Credentials(principal, token);
    security.changePassword(credentials, toChange);
}
Also used : PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) TCredentials(org.apache.accumulo.core.securityImpl.thrift.TCredentials) Credentials(org.apache.accumulo.core.clientImpl.Credentials)

Example 10 with Credentials

use of org.apache.accumulo.core.clientImpl.Credentials in project accumulo by apache.

the class ClientServiceHandler method createLocalUser.

@Override
public void createLocalUser(TInfo tinfo, TCredentials credentials, String principal, ByteBuffer password) throws ThriftSecurityException {
    AuthenticationToken token;
    if (context.getSaslParams() != null) {
        try {
            token = new KerberosToken();
        } catch (IOException e) {
            log.warn("Failed to create KerberosToken");
            throw new ThriftSecurityException(e.getMessage(), SecurityErrorCode.DEFAULT_SECURITY_ERROR);
        }
    } else {
        token = new PasswordToken(password);
    }
    Credentials newUser = new Credentials(principal, token);
    security.createUser(credentials, newUser, new Authorizations());
}
Also used : PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) Authorizations(org.apache.accumulo.core.security.Authorizations) AuthenticationToken(org.apache.accumulo.core.client.security.tokens.AuthenticationToken) KerberosToken(org.apache.accumulo.core.client.security.tokens.KerberosToken) IOException(java.io.IOException) ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) TCredentials(org.apache.accumulo.core.securityImpl.thrift.TCredentials) Credentials(org.apache.accumulo.core.clientImpl.Credentials)

Aggregations

Credentials (org.apache.accumulo.core.clientImpl.Credentials)19 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)13 TCredentials (org.apache.accumulo.core.securityImpl.thrift.TCredentials)10 Test (org.junit.Test)8 AccumuloClient (org.apache.accumulo.core.client.AccumuloClient)7 Text (org.apache.hadoop.io.Text)5 Test (org.junit.jupiter.api.Test)5 BatchWriter (org.apache.accumulo.core.client.BatchWriter)4 Value (org.apache.accumulo.core.data.Value)4 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)3 Scanner (org.apache.accumulo.core.client.Scanner)3 SecurityOperations (org.apache.accumulo.core.client.admin.SecurityOperations)3 ClientContext (org.apache.accumulo.core.clientImpl.ClientContext)3 Writer (org.apache.accumulo.core.clientImpl.Writer)3 Key (org.apache.accumulo.core.data.Key)3 Mutation (org.apache.accumulo.core.data.Mutation)3 Authorizations (org.apache.accumulo.core.security.Authorizations)3 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 File (java.io.File)2 PrintStream (java.io.PrintStream)2