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);
}
}
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);
}
}
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)));
}
}
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));
}
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));
}
Aggregations