use of cn.edu.tsinghua.iginx.thrift.UserType in project IginX by thulab.
the class UsersClientImpl method findUsers.
@Override
public List<User> findUsers() throws IginXException {
GetUserReq req = new GetUserReq(sessionId);
GetUserResp resp;
synchronized (iginXClient) {
iginXClient.checkIsClosed();
try {
resp = client.getUser(req);
RpcUtils.verifySuccess(resp.status);
} catch (TException | ExecutionException e) {
throw new IginXException("find users failure: ", e);
}
}
if (resp.usernames == null || resp.userTypes == null || resp.auths == null) {
return Collections.emptyList();
}
List<User> users = new ArrayList<>();
for (int i = 0; i < resp.usernames.size(); i++) {
String username = resp.usernames.get(i);
UserType userType = resp.userTypes.get(i);
Set<AuthType> auths = resp.auths.get(i);
users.add(new User(username, userType, auths));
}
return users;
}
use of cn.edu.tsinghua.iginx.thrift.UserType in project IginX by thulab.
the class DefaultMetaManager method resolveUserFromConf.
private UserMeta resolveUserFromConf() {
String username = ConfigDescriptor.getInstance().getConfig().getUsername();
String password = ConfigDescriptor.getInstance().getConfig().getPassword();
UserType userType = UserType.Administrator;
Set<AuthType> auths = new HashSet<>();
auths.add(AuthType.Read);
auths.add(AuthType.Write);
auths.add(AuthType.Admin);
auths.add(AuthType.Cluster);
return new UserMeta(username, password, userType, auths);
}
use of cn.edu.tsinghua.iginx.thrift.UserType in project IginX by thulab.
the class UsersClientImpl method findUserByName.
@Override
public User findUserByName(String username) throws IginXException {
Arguments.checkNotNull(username, "username");
GetUserReq req = new GetUserReq(sessionId);
req.setUsernames(Collections.singletonList(username));
GetUserResp resp;
synchronized (iginXClient) {
iginXClient.checkIsClosed();
try {
resp = client.getUser(req);
RpcUtils.verifySuccess(resp.status);
} catch (TException | ExecutionException e) {
throw new IginXException("find user failure: ", e);
}
}
if (resp.usernames == null || resp.usernames.isEmpty()) {
return null;
}
UserType userType = resp.userTypes.get(0);
Set<AuthType> auths = resp.auths.get(0);
return new User(username, userType, auths);
}
Aggregations