use of com.sequenceiq.freeipa.client.model.User in project cloudbreak by hortonworks.
the class UserModResponse method handleInternal.
@Override
protected User handleInternal(List<CloudVmMetaDataStatus> metadatas, String body) {
User user = new User();
user.setDn("admin");
user.setUid("admin");
user.setMemberOfGroup(List.of("admins"));
user.setKrbPasswordExpiration("20290101000000Z");
return user;
}
use of com.sequenceiq.freeipa.client.model.User in project cloudbreak by hortonworks.
the class UserModOperationTest method testInvoke.
@Test
public void testInvoke() throws FreeIpaClientException {
RPCResponse<Object> rpcResponse = new RPCResponse<>();
rpcResponse.setResult(new User());
when(freeIpaClient.invoke(any(), anyList(), any(), any())).thenReturn(rpcResponse);
UserModOperation.create("key", new Object(), USER_NAME).invoke(freeIpaClient);
verify(freeIpaClient).invoke(eq("user_mod"), anyList(), any(), any());
}
use of com.sequenceiq.freeipa.client.model.User in project cloudbreak by hortonworks.
the class FreeIpaClient method userFind.
public Optional<User> userFind(String user) throws FreeIpaClientException {
List<Object> flags = List.of(user);
Map<String, Object> params = Map.of("uid", user, "all", true);
ParameterizedType type = TypeUtils.parameterize(List.class, User.class);
List<User> foundUsers = (List<User>) invoke("user_find", flags, params, type).getResult();
if (foundUsers.size() > 1) {
LOGGER.error("Found more than 1 user with uid {}.", user);
}
if (foundUsers.isEmpty()) {
return Optional.empty();
} else {
return Optional.of(foundUsers.get(0));
}
}
use of com.sequenceiq.freeipa.client.model.User in project cloudbreak by hortonworks.
the class UserAddOperation method invoke.
@Override
public Optional<User> invoke(FreeIpaClient freeIpaClient) throws FreeIpaClientException {
FreeIpaChecks.checkUserNotProtected(user, () -> String.format("User '%s' is protected and cannot be added to FreeIPA", user));
LOGGER.debug("adding user {}", user);
User user = invoke(freeIpaClient, User.class);
LOGGER.debug("added user {}", user);
return Optional.of(user);
}
use of com.sequenceiq.freeipa.client.model.User in project cloudbreak by hortonworks.
the class UserModOperation method invoke.
@Override
public Optional<User> invoke(FreeIpaClient freeIpaClient) throws FreeIpaClientException {
try {
LOGGER.debug("modifying user {}", user);
User modified = invoke(freeIpaClient, User.class);
LOGGER.debug("modified user {}", user);
return Optional.of(modified);
} catch (FreeIpaClientException e) {
if (FreeIpaClientExceptionUtil.isEmptyModlistException(e)) {
LOGGER.debug("Workload credentials for user '{}' already set.", getUser());
} else {
throw e;
}
}
return Optional.empty();
}
Aggregations