Search in sources :

Example 6 with DbUser

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);
}
Also used : DirectoryUser(org.ovirt.engine.core.aaa.DirectoryUser) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) Guid(org.ovirt.engine.core.compat.Guid) AddUserParameters(org.ovirt.engine.core.common.action.AddUserParameters) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 7 with DbUser

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;
}
Also used : ArrayList(java.util.ArrayList) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 8 with DbUser

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);
    }
}
Also used : ServletException(javax.servlet.ServletException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) RequestDispatcher(javax.servlet.RequestDispatcher) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 9 with DbUser

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);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) HashSet(java.util.HashSet) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 10 with DbUser

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);
        }
    }
}
Also used : DirectoryGroup(org.ovirt.engine.core.aaa.DirectoryGroup) Queryable(org.ovirt.engine.core.common.businessentities.Queryable) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) Collection(java.util.Collection) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Aggregations

DbUser (org.ovirt.engine.core.common.businessentities.aaa.DbUser)109 Test (org.junit.Test)26 ArrayList (java.util.ArrayList)18 Guid (org.ovirt.engine.core.compat.Guid)18 DbGroup (org.ovirt.engine.core.common.businessentities.aaa.DbGroup)13 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)10 HashSet (java.util.HashSet)9 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)9 HashMap (java.util.HashMap)8 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)8 Collection (java.util.Collection)7 Before (org.junit.Before)7 Permission (org.ovirt.engine.core.common.businessentities.Permission)7 List (java.util.List)5 Map (java.util.Map)5 AttachEntityToTagParameters (org.ovirt.engine.core.common.action.AttachEntityToTagParameters)5 PermissionsOperationsParameters (org.ovirt.engine.core.common.action.PermissionsOperationsParameters)5 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)5 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)5 TagListModel (org.ovirt.engine.ui.uicommonweb.models.tags.TagListModel)5