Search in sources :

Example 1 with User

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;
}
Also used : User(com.sequenceiq.freeipa.client.model.User)

Example 2 with 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());
}
Also used : User(com.sequenceiq.freeipa.client.model.User) RPCResponse(com.sequenceiq.cloudbreak.client.RPCResponse) Test(org.junit.jupiter.api.Test)

Example 3 with User

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));
    }
}
Also used : ParameterizedType(java.lang.reflect.ParameterizedType) User(com.sequenceiq.freeipa.client.model.User) List(java.util.List)

Example 4 with User

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);
}
Also used : User(com.sequenceiq.freeipa.client.model.User)

Example 5 with 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();
}
Also used : User(com.sequenceiq.freeipa.client.model.User) FreeIpaClientException(com.sequenceiq.freeipa.client.FreeIpaClientException)

Aggregations

User (com.sequenceiq.freeipa.client.model.User)38 FreeIpaClient (com.sequenceiq.freeipa.client.FreeIpaClient)15 Test (org.junit.jupiter.api.Test)13 Map (java.util.Map)11 RPCResponse (com.sequenceiq.cloudbreak.client.RPCResponse)10 Set (java.util.Set)8 FreeIpaClientException (com.sequenceiq.freeipa.client.FreeIpaClientException)7 FmsUser (com.sequenceiq.freeipa.service.freeipa.user.model.FmsUser)7 List (java.util.List)7 Test (org.junit.Test)5 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 UserMetadata (com.sequenceiq.freeipa.service.freeipa.user.model.UserMetadata)4 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)3 SetPasswordRequest (com.sequenceiq.freeipa.flow.freeipa.user.event.SetPasswordRequest)3 FmsGroup (com.sequenceiq.freeipa.service.freeipa.user.model.FmsGroup)3 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)2 HashMultimap (com.google.common.collect.HashMultimap)2 Multimap (com.google.common.collect.Multimap)2 JsonRpcClientException (com.googlecode.jsonrpc4j.JsonRpcClientException)2 FreeIpaErrorCodes (com.sequenceiq.freeipa.client.FreeIpaErrorCodes)2