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);
}
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);
}
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);
}
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;
}
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;
}
Aggregations