Search in sources :

Example 16 with User

use of org.ovirt.engine.api.model.User in project ovirt-engine by oVirt.

the class BackendUsersResourceTest method testAddUser4.

@Test
public void testAddUser4() throws Exception {
    setUpEntityQueryExpectations(QueryType.GetDomainList, QueryParametersBase.class, new String[] {}, new Object[] {}, setUpDomains());
    setUpAddUserExpectations("ADUSER@" + DOMAIN + ":: username=" + NAMES[0]);
    User model = new User();
    model.setUserName(NAMES[0]);
    Domain domain = new Domain();
    domain.setName(DOMAIN);
    domain.setId(DirectoryEntryIdUtils.encode(domain.getName()));
    model.setDomain(domain);
    Response response = collection.add(model);
    verifyAddUser(response);
}
Also used : Response(javax.ws.rs.core.Response) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) DirectoryUser(org.ovirt.engine.core.aaa.DirectoryUser) User(org.ovirt.engine.api.model.User) Domain(org.ovirt.engine.api.model.Domain) Test(org.junit.Test) AbstractBackendCollectionResourceTest(org.ovirt.engine.api.restapi.resource.AbstractBackendCollectionResourceTest)

Example 17 with User

use of org.ovirt.engine.api.model.User in project ovirt-engine by oVirt.

the class BackendUsersResourceTest method testAddUser3.

@Test
public void testAddUser3() throws Exception {
    setUpEntityQueryExpectations(QueryType.GetDomainList, QueryParametersBase.class, new String[] {}, new Object[] {}, setUpDomains());
    setUpAddUserExpectations("ADUSER@" + DOMAIN + ":: username=" + NAMES[0]);
    User model = new User();
    model.setUserName(NAMES[0] + "@" + DOMAIN);
    Response response = collection.add(model);
    verifyAddUser(response);
}
Also used : Response(javax.ws.rs.core.Response) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) DirectoryUser(org.ovirt.engine.core.aaa.DirectoryUser) User(org.ovirt.engine.api.model.User) Test(org.junit.Test) AbstractBackendCollectionResourceTest(org.ovirt.engine.api.restapi.resource.AbstractBackendCollectionResourceTest)

Example 18 with User

use of org.ovirt.engine.api.model.User in project ovirt-engine by oVirt.

the class BackendAssignedPermissionsResource method map.

/**
 * injects user/group base on permission owner type
 * @param entity the permission to map
 * @param user the permission owner
 * @return permission
 */
public Permission map(org.ovirt.engine.core.common.businessentities.Permission entity, DbUser user) {
    Permission template = new Permission();
    if (entity.getAdElementId() != null) {
        if (isUser(user)) {
            template.setUser(new User());
            template.getUser().setId(entity.getAdElementId().toString());
        } else {
            template.setGroup(new Group());
            template.getGroup().setId(entity.getAdElementId().toString());
        }
    }
    return map(entity, template);
}
Also used : Group(org.ovirt.engine.api.model.Group) DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup) User(org.ovirt.engine.api.model.User) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) Permission(org.ovirt.engine.api.model.Permission)

Example 19 with User

use of org.ovirt.engine.api.model.User in project ovirt-engine by oVirt.

the class BackendAssignedPermissionsResource method getPrincipal.

/**
 * Find the user or group that the permissions applies to.
 *
 * @param permission the incoming permission model
 * @return the user or group that the permission applies to
 */
private Object getPrincipal(Permission permission) {
    if (isUserSubCollection()) {
        DbUser dbUser = new DbUser();
        dbUser.setId(targetId);
        return dbUser;
    }
    if (isGroupSubCollection()) {
        DbGroup dbGroup = new DbGroup();
        dbGroup.setId(targetId);
        return dbGroup;
    }
    if (permission.isSetUser()) {
        User user = permission.getUser();
        DbUser dbUser = UserMapper.map(user, null);
        if (dbUser.getDomain() == null) {
            dbUser.setDomain(getCurrent().getUser().getDomain());
        }
        return dbUser;
    }
    if (permission.isSetGroup()) {
        Group group = permission.getGroup();
        DbGroup dbGroup = GroupMapper.map(group, null);
        if (dbGroup.getDomain() == null) {
            dbGroup.setDomain(getCurrent().getUser().getDomain());
        }
        return dbGroup;
    }
    return null;
}
Also used : DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup) Group(org.ovirt.engine.api.model.Group) DbGroup(org.ovirt.engine.core.common.businessentities.aaa.DbGroup) User(org.ovirt.engine.api.model.User) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 20 with User

use of org.ovirt.engine.api.model.User in project ovirt-engine by oVirt.

the class BackendAssignedRolesResource method addParents.

@Override
protected Role addParents(Role role) {
    role.setUser(new User());
    role.getUser().setId(principalId.toString());
    return role;
}
Also used : User(org.ovirt.engine.api.model.User)

Aggregations

User (org.ovirt.engine.api.model.User)31 Test (org.junit.Test)12 DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)9 Role (org.ovirt.engine.api.model.Role)7 Permission (org.ovirt.engine.api.model.Permission)6 DirectoryUser (org.ovirt.engine.core.aaa.DirectoryUser)6 Roles (org.ovirt.engine.api.model.Roles)5 Domain (org.ovirt.engine.api.model.Domain)4 WebApplicationException (javax.ws.rs.WebApplicationException)3 Response (javax.ws.rs.core.Response)3 Group (org.ovirt.engine.api.model.Group)3 AbstractBackendCollectionResourceTest (org.ovirt.engine.api.restapi.resource.AbstractBackendCollectionResourceTest)3 Groups (org.ovirt.engine.api.model.Groups)2 Session (org.ovirt.engine.api.model.Session)2 Ssh (org.ovirt.engine.api.model.Ssh)2 Users (org.ovirt.engine.api.model.Users)2 DbGroup (org.ovirt.engine.core.common.businessentities.aaa.DbGroup)2 ArrayList (java.util.ArrayList)1 AuthorizedKey (org.ovirt.engine.api.model.AuthorizedKey)1 BaseResource (org.ovirt.engine.api.model.BaseResource)1