use of org.ovirt.engine.core.common.businessentities.aaa.DbUser in project ovirt-engine by oVirt.
the class BackendUsersResource method add.
@Override
public Response add(User user) {
validateParameters(user, "userName");
List<String> authzProvidersNames = getBackendCollection(String.class, QueryType.GetDomainList, new QueryParametersBase());
if (AuthzUtils.getAuthzNameFromEntityName(user.getUserName(), authzProvidersNames) == null) {
// user-name may contain the domain (e.g: oliel@xxx.yyy)
validateParameters(user, "domain.id|name");
}
String domain = getAuthzProviderName(user, authzProvidersNames);
DirectoryUser directoryUser = findDirectoryUser(domain, user);
if (directoryUser == null) {
return Response.status(Status.BAD_REQUEST).entity("No such user: " + user.getUserName() + " in domain " + domain).build();
}
AddUserParameters parameters = new AddUserParameters(new DbUser(directoryUser));
QueryIdResolver<Guid> resolver = new QueryIdResolver<>(QueryType.GetDbUserByUserId, IdQueryParameters.class);
return performCreate(ActionType.AddUser, parameters, resolver, BaseResource.class);
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbUser in project ovirt-engine by oVirt.
the class BackendPermissionResourceTest method getUsers.
protected ArrayList<DbUser> getUsers() {
ArrayList<DbUser> users = new ArrayList<>();
for (int i = 0; i < NAMES.length; i++) {
DbUser user = new DbUser();
user.setId(GUIDS[i]);
user.setLoginName(NAMES[i]);
users.add(user);
}
return users;
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbUser in project ovirt-engine by oVirt.
the class GwtDynamicHostPageServlet method doGet.
@Override
protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException {
final String engineSessionId = getEngineSessionId(request);
// Set attribute for selector script
request.setAttribute(MD5Attributes.ATTR_SELECTOR_SCRIPT.getKey(), getSelectorScriptName());
// Set the messages that need to be replaced.
request.setAttribute(MD5Attributes.ATTR_MESSAGES.getKey(), getBrandingMessages(getApplicationTypeFromRequest(request), getLocaleFromRequest(request)));
request.setAttribute(MD5Attributes.ATTR_BASE_CONTEXT_PATH.getKey(), getValueObject(ServletUtils.getBaseContextPath(request)));
request.setAttribute(MD5Attributes.ATTR_DISPLAY_UNCAUGHT_UI_EXCEPTIONS.getKey(), getDisplayUncaughtUIExceptions() ? BooleanNode.TRUE : BooleanNode.FALSE);
// Set attributes for userInfo object
DbUser loggedInUser = getLoggedInUser(engineSessionId);
if (loggedInUser != null) {
String ssoToken = getSsoToken(engineSessionId);
request.setAttribute(MD5Attributes.ATTR_USER_INFO.getKey(), getUserInfoObject(loggedInUser, ssoToken));
}
// Set attribute for engineRpmVersion object
String engineRpmVersion = getEngineRpmVersion(engineSessionId);
request.setAttribute(MD5Attributes.ATTR_ENGINE_RPM_VERSION.getKey(), getValueObject(engineRpmVersion));
try {
// Calculate MD5 for use with If-None-Match request header
String md5sum = getMd5Sum(request);
if (request.getHeader(IF_NONE_MATCH_HEADER) != null && request.getHeader(IF_NONE_MATCH_HEADER).equals(md5sum)) {
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
} else {
RequestDispatcher dispatcher = request.getRequestDispatcher(HOST_JSP);
response.setContentType(UTF_CONTENT_TYPE);
response.addHeader(ETAG_HEADER, md5sum);
if (dispatcher != null) {
dispatcher.include(request, response);
}
}
} catch (NoSuchAlgorithmException ex) {
throw new ServletException(ex);
}
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbUser in project ovirt-engine by oVirt.
the class AdElementListModel method syncSearchGroups.
private void syncSearchGroups() {
AsyncQuery<QueryReturnValue> asyncQuery = new AsyncQuery<>(queryReturnValue -> {
if (handleQueryError(queryReturnValue)) {
return;
}
HashSet<String> excludeUsers = new HashSet<>();
if (getExcludeItems() != null) {
for (DbUser item : getExcludeItems()) {
excludeUsers.add(item.getExternalId());
}
}
setgroups(new ArrayList<>());
addGroupsToModel(queryReturnValue, excludeUsers);
onAdGroupsLoaded();
});
asyncQuery.setHandleFailure(true);
findGroups(// $NON-NLS-1$ //$NON-NLS-2$
"name=" + (StringHelper.isNullOrEmpty(getSearchString()) ? "*" : getSearchString()), asyncQuery);
}
use of org.ovirt.engine.core.common.businessentities.aaa.DbUser in project ovirt-engine by oVirt.
the class AdElementListModel method addGroupsToModel.
protected void addGroupsToModel(QueryReturnValue returnValue, Set<String> excludeUsers) {
for (Queryable item : (Collection<Queryable>) returnValue.getReturnValue()) {
DirectoryGroup a = (DirectoryGroup) item;
if (!excludeUsers.contains(a.getId())) {
// TODO: This is a hack, we should either use DbGroup or reimplement user/group representation in GWT
DbUser group = new DbUser();
group.setExternalId(a.getId());
group.setFirstName(a.getName());
// $NON-NLS-1$
group.setLastName("");
// TODO: Due to group -> DbUser mapping hack we have to use note to represent display name of group
group.setNote(a.getDisplayName());
group.setDomain(a.getDirectoryName());
group.setNamespace(a.getNamespace());
EntityModel<DbUser> groupEntity = new EntityModel<>();
groupEntity.setEntity(group);
getgroups().add(groupEntity);
}
}
}
Aggregations