Search in sources :

Example 36 with User

use of org.gluu.oxtrust.model.scim2.User in project openstack4j by ContainX.

the class KeystoneUserServiceTests method crud_User_Test.

/**
     * CRUD user tests
     *
     * @throws Exception
     */
public void crud_User_Test() throws Exception {
    // --create
    respondWith(JSON_USER_CREATE);
    User newUser = osv3().identity().users().create(USER_DOMAIN_ID, "foobar", "secret", "foobar@example.org", true);
    assertEquals(newUser.getName(), "foobar");
    assertEquals(newUser.getDomainId(), USER_DOMAIN_ID);
    assertEquals(newUser.getEmail(), "foobar@example.org");
    assertEquals(newUser.isEnabled(), true);
    assertNotNull(newUser.getId());
    // --read
    respondWith(JSON_USER_READ);
    User user = osv3().identity().users().getByName("foobar", USER_DOMAIN_ID);
    assertEquals(user.getId(), newUser.getId());
    assertEquals(user.getName(), "foobar");
    assertEquals(user.getEmail(), "foobar@example.org");
    assertEquals(user.isEnabled(), true);
    assertEquals(user.getDomainId(), USER_DOMAIN_ID);
    String crudUserId = user.getId();
    // --update
    respondWith(JSON_USER_UPDATE);
    User updatedUser = osv3().identity().users().update(KeystoneUser.builder().id(crudUserId).email("updatedFoobar@example.org").enabled(true).build());
    assertEquals(updatedUser.getEmail(), "updatedFoobar@example.org");
    assertEquals(updatedUser.getName(), "foobar");
    assertEquals(updatedUser.isEnabled(), true);
    assertEquals(updatedUser.getId(), crudUserId);
    assertEquals(updatedUser.getDomainId(), USER_DOMAIN_ID);
    // --delete
    respondWith(204);
    ActionResponse response_delete = osv3().identity().users().delete(crudUserId);
    assertTrue(response_delete.isSuccess());
}
Also used : KeystoneUser(org.openstack4j.openstack.identity.v3.domain.KeystoneUser) User(org.openstack4j.model.identity.v3.User) ActionResponse(org.openstack4j.model.common.ActionResponse)

Example 37 with User

use of org.gluu.oxtrust.model.scim2.User in project openstack4j by ContainX.

the class KeystoneUserServiceTests method getUser_byId_Test.

/**
     * get speciific user by user identifier
     *
     * @throws Exception
     */
public void getUser_byId_Test() throws Exception {
    respondWith(JSON_USER_GET_BYID);
    User user = osv3().identity().users().get(USER_ID);
    assertEquals(user.getId(), USER_ID);
    assertEquals(user.getName(), USER_NAME);
    assertEquals(user.getDomainId(), USER_DOMAIN_ID);
}
Also used : KeystoneUser(org.openstack4j.openstack.identity.v3.domain.KeystoneUser) User(org.openstack4j.model.identity.v3.User)

Example 38 with User

use of org.gluu.oxtrust.model.scim2.User in project openstack4j by ContainX.

the class KeystoneUserServiceTests method getUser_byName_byDomainId_Test.

/**
     * returns the user specified by name and domain.
     *
     * @throws Exception
     */
public void getUser_byName_byDomainId_Test() throws Exception {
    respondWith(JSON_USER_GET_BYNAME_BYDOMAINID);
    User user = osv3().identity().users().getByName(USER_NAME, USER_DOMAIN_ID);
    assertEquals(user.getName(), USER_NAME);
    assertEquals(user.getId(), USER_ID);
    assertEquals(user.getDomainId(), USER_DOMAIN_ID);
}
Also used : KeystoneUser(org.openstack4j.openstack.identity.v3.domain.KeystoneUser) User(org.openstack4j.model.identity.v3.User)

Example 39 with User

use of org.gluu.oxtrust.model.scim2.User in project camel by apache.

the class UserProducer method messageToUser.

private User messageToUser(Message message) {
    User project = message.getBody(User.class);
    if (project == null) {
        Map headers = message.getHeaders();
        UserBuilder builder = Builders.user();
        ObjectHelper.notEmpty(message.getHeader(OpenstackConstants.NAME, String.class), "Name");
        builder.name(message.getHeader(OpenstackConstants.NAME, String.class));
        if (headers.containsKey(KeystoneConstants.DOMAIN_ID)) {
            builder.domainId(message.getHeader(KeystoneConstants.DOMAIN_ID, String.class));
        }
        if (headers.containsKey(KeystoneConstants.DESCRIPTION)) {
            builder.description(message.getHeader(KeystoneConstants.DESCRIPTION, String.class));
        }
        if (headers.containsKey(KeystoneConstants.PASSWORD)) {
            builder.password(message.getHeader(KeystoneConstants.PASSWORD, String.class));
        }
        if (headers.containsKey(KeystoneConstants.EMAIL)) {
            builder.email(message.getHeader(KeystoneConstants.EMAIL, String.class));
        }
        project = builder.build();
    }
    return project;
}
Also used : User(org.openstack4j.model.identity.v3.User) Map(java.util.Map) UserBuilder(org.openstack4j.model.identity.v3.builder.UserBuilder)

Example 40 with User

use of org.gluu.oxtrust.model.scim2.User in project camel by apache.

the class UserProducer method doGet.

private void doGet(Exchange exchange) {
    final Message msg = exchange.getIn();
    final String id = msg.getHeader(OpenstackConstants.ID, msg.getHeader(KeystoneConstants.USER_ID, String.class), String.class);
    ObjectHelper.notEmpty(id, "User ID");
    final User result = osV3Client.identity().users().get(id);
    msg.setBody(result);
}
Also used : User(org.openstack4j.model.identity.v3.User) Message(org.apache.camel.Message)

Aggregations

GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)18 User (org.gluu.oxtrust.model.scim2.User)17 ArrayList (java.util.ArrayList)13 Response (javax.ws.rs.core.Response)13 DefaultValue (javax.ws.rs.DefaultValue)12 HeaderParam (javax.ws.rs.HeaderParam)12 Produces (javax.ws.rs.Produces)12 URI (java.net.URI)11 ListResponse (org.gluu.oxtrust.model.scim2.ListResponse)11 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)10 ScimPatchUser (org.gluu.oxtrust.model.scim2.ScimPatchUser)10 DuplicateEntryException (org.gluu.site.ldap.exception.DuplicateEntryException)10 User (org.openstack4j.model.identity.v3.User)10 Date (java.util.Date)9 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)8 PersonRequiredFieldsException (org.gluu.oxtrust.exception.PersonRequiredFieldsException)8 EntryPersistenceException (org.gluu.site.ldap.persistence.exception.EntryPersistenceException)8 IOException (java.io.IOException)7 Map (java.util.Map)7 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)7