Search in sources :

Example 36 with AccessToken

use of com.cinchapi.concourse.thrift.AccessToken in project concourse by cinchapi.

the class ConcourseIntegrationTest method disableUser.

/**
 * Disable access to the server for the user identified by {@code username}.
 *
 * @param username the username for which access should be disabled
 */
protected final void disableUser(String username) {
    try {
        AccessToken token = server.login(ByteBuffers.fromUtf8String("admin"), ByteBuffers.fromUtf8String("admin"));
        server.disableUser(ByteBuffers.fromUtf8String(username), token);
    } catch (TException e) {
        throw CheckedExceptions.wrapAsRuntimeException(e);
    }
}
Also used : TException(org.apache.thrift.TException) AccessToken(com.cinchapi.concourse.thrift.AccessToken)

Example 37 with AccessToken

use of com.cinchapi.concourse.thrift.AccessToken in project concourse by cinchapi.

the class ConcourseIntegrationTest method grant.

/**
 * Grant permissions
 *
 * @param username
 * @param permission
 * @param environment
 */
protected final void grant(String username, String permission, String environment) {
    try {
        AccessToken token = server.login(ByteBuffers.fromUtf8String("admin"), ByteBuffers.fromUtf8String("admin"));
        server.grant(ByteBuffers.fromUtf8String(username), permission, environment, token);
    } catch (TException e) {
        throw CheckedExceptions.wrapAsRuntimeException(e);
    }
}
Also used : TException(org.apache.thrift.TException) AccessToken(com.cinchapi.concourse.thrift.AccessToken)

Example 38 with AccessToken

use of com.cinchapi.concourse.thrift.AccessToken in project concourse by cinchapi.

the class RemoteMethodRequest method deserialize.

@Override
public void deserialize(Buffer buffer) {
    this.method = buffer.readUTF8();
    byte[] creds0 = new byte[buffer.readInt()];
    buffer.read(creds0);
    this.creds = new AccessToken(ByteBuffer.wrap(creds0));
    boolean transaction0 = buffer.readByte() == 1 ? true : false;
    this.transaction = null;
    if (transaction0) {
        long timestamp = buffer.readLong();
        this.transaction = new TransactionToken(creds, timestamp);
    }
    this.environment = buffer.readUTF8();
    this.args = Lists.newArrayList();
    while (buffer.hasRemaining()) {
        int length = buffer.readInt();
        byte[] arg = new byte[length];
        buffer.read(arg);
        args.add(ComplexTObject.fromByteBuffer(ByteBuffer.wrap(arg)));
    }
}
Also used : TransactionToken(com.cinchapi.concourse.thrift.TransactionToken) AccessToken(com.cinchapi.concourse.thrift.AccessToken)

Example 39 with AccessToken

use of com.cinchapi.concourse.thrift.AccessToken in project concourse by cinchapi.

the class UserServiceTest method testTwoAccessTokensForSameUser.

@Test
public void testTwoAccessTokensForSameUser() {
    ByteBuffer username = getAcceptableUsername();
    ByteBuffer password = getSecurePassword();
    service.create(username, password, Role.ADMIN);
    AccessToken token1 = service.tokens.issue(username);
    AccessToken token2 = service.tokens.issue(username);
    Assert.assertNotEquals(token1, token2);
    Assert.assertTrue(service.tokens.isValid(token1));
    Assert.assertTrue(service.tokens.isValid(token2));
}
Also used : AccessToken(com.cinchapi.concourse.thrift.AccessToken) ByteBuffer(java.nio.ByteBuffer) ConcourseBaseTest(com.cinchapi.concourse.test.ConcourseBaseTest) Test(org.junit.Test)

Example 40 with AccessToken

use of com.cinchapi.concourse.thrift.AccessToken in project concourse by cinchapi.

the class UserServiceTest method testAccessTokenIsNotValidIfServerRestarts.

@Test
public void testAccessTokenIsNotValidIfServerRestarts() {
    ByteBuffer username = getAcceptableUsername();
    ByteBuffer password = getSecurePassword();
    service.create(username, password, Role.ADMIN);
    AccessToken token = service.tokens.issue(username);
    // simulate
    UserService service2 = UserService.create(current);
    // server
    // restart by
    // creating new
    // service
    Assert.assertFalse(service2.tokens.isValid(token));
}
Also used : AccessToken(com.cinchapi.concourse.thrift.AccessToken) ByteBuffer(java.nio.ByteBuffer) ConcourseBaseTest(com.cinchapi.concourse.test.ConcourseBaseTest) Test(org.junit.Test)

Aggregations

AccessToken (com.cinchapi.concourse.thrift.AccessToken)96 ByteBuffer (java.nio.ByteBuffer)72 TransactionToken (com.cinchapi.concourse.thrift.TransactionToken)60 TException (org.apache.thrift.TException)60 AtomicReference (java.util.concurrent.atomic.AtomicReference)56 AnyStrings (com.cinchapi.common.base.AnyStrings)55 CheckedExceptions (com.cinchapi.common.base.CheckedExceptions)55 Reflection (com.cinchapi.common.reflect.Reflection)55 Permission (com.cinchapi.concourse.security.Permission)55 Role (com.cinchapi.concourse.security.Role)55 Internal (com.cinchapi.concourse.server.aop.Internal)55 VerifyAccessToken (com.cinchapi.concourse.server.aop.VerifyAccessToken)55 VerifyReadPermission (com.cinchapi.concourse.server.aop.VerifyReadPermission)55 VerifyWritePermission (com.cinchapi.concourse.server.aop.VerifyWritePermission)55 FileSystem (com.cinchapi.concourse.server.io.FileSystem)55 ConcourseManagementService (com.cinchapi.concourse.server.management.ConcourseManagementService)55 PluginManager (com.cinchapi.concourse.server.plugin.PluginManager)55 AbstractSyntaxTree (com.cinchapi.ccl.syntax.AbstractSyntaxTree)28 NaturalLanguage (com.cinchapi.ccl.util.NaturalLanguage)28 Array (com.cinchapi.common.base.Array)28