Search in sources :

Example 1 with User

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

the class BackendApiResource method setAuthenticatedUser.

/**
 * Set a link to the user of the current session
 * (the 'authenticated user') in the API object.
 * This link enables users a convenient way to see
 * which is the logged-in user, using the system.
 */
private void setAuthenticatedUser(Api api) {
    QueryReturnValue returnValue = runQuery(QueryType.GetUserBySessionId, new QueryParametersBase());
    DbUser authenticatedUser = (DbUser) returnValue.getReturnValue();
    User user = new User();
    user.setId(authenticatedUser.getId().toString());
    LinkHelper.addLinks(user);
    api.setAuthenticatedUser(user);
    api.setEffectiveUser(user);
// currently the authenticated and effective users are the same one,
// but if and when impersonation is introduced, they may be different.
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser) User(org.ovirt.engine.api.model.User) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) DbUser(org.ovirt.engine.core.common.businessentities.aaa.DbUser)

Example 2 with User

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

the class BackendSSHPublicKeysResource method addParents.

@Override
public SshPublicKey addParents(SshPublicKey pubkey) {
    User parent = pubkey.getUser();
    if (parent == null) {
        parent = new User();
        pubkey.setUser(parent);
    }
    parent.setId(userId.toString());
    return pubkey;
}
Also used : User(org.ovirt.engine.api.model.User)

Example 3 with User

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

the class CompletenessAssertorTest method testMissingListSubFieldAlternatives.

@Test
public void testMissingListSubFieldAlternatives() throws Exception {
    User user = new User();
    user.setRoles(new Roles());
    user.getRoles().getRoles().add(new Role());
    user.getRoles().getRoles().get(0).setId("0");
    user.getRoles().getRoles().add(new Role());
    user.getRoles().getRoles().get(1).setDescription("0");
    try {
        CompletenessAssertor.validateParameters(user, "roles.id|name");
        fail("expected WebApplicationException on incomplete model");
    } catch (WebApplicationException wae) {
        verifyIncompleteException(wae, "User", "roles.id|name");
    }
}
Also used : Role(org.ovirt.engine.api.model.Role) User(org.ovirt.engine.api.model.User) WebApplicationException(javax.ws.rs.WebApplicationException) Roles(org.ovirt.engine.api.model.Roles) Test(org.junit.Test)

Example 4 with User

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

the class V3UserInAdapter method adapt.

@Override
public User adapt(V3User from) {
    User to = new User();
    if (from.isSetLinks()) {
        to.getLinks().addAll(adaptIn(from.getLinks()));
    }
    if (from.isSetActions()) {
        to.setActions(adaptIn(from.getActions()));
    }
    if (from.isSetComment()) {
        to.setComment(from.getComment());
    }
    if (from.isSetDepartment()) {
        to.setDepartment(from.getDepartment());
    }
    if (from.isSetDescription()) {
        to.setDescription(from.getDescription());
    }
    if (from.isSetDomain()) {
        to.setDomain(adaptIn(from.getDomain()));
    }
    if (from.isSetDomainEntryId()) {
        to.setDomainEntryId(from.getDomainEntryId());
    }
    if (from.isSetEmail()) {
        to.setEmail(from.getEmail());
    }
    if (from.isSetGroups()) {
        to.setGroups(new Groups());
        to.getGroups().getGroups().addAll(adaptIn(from.getGroups().getGroups()));
    }
    if (from.isSetId()) {
        to.setId(from.getId());
    }
    if (from.isSetHref()) {
        to.setHref(from.getHref());
    }
    if (from.isSetLastName()) {
        to.setLastName(from.getLastName());
    }
    if (from.isSetLoggedIn()) {
        to.setLoggedIn(from.isLoggedIn());
    }
    if (from.isSetName()) {
        to.setName(from.getName());
    }
    if (from.isSetNamespace()) {
        to.setNamespace(from.getNamespace());
    }
    if (from.isSetPassword()) {
        to.setPassword(from.getPassword());
    }
    if (from.isSetPrincipal()) {
        to.setPrincipal(from.getPrincipal());
    }
    if (from.isSetRoles()) {
        to.setRoles(new Roles());
        to.getRoles().getRoles().addAll(adaptIn(from.getRoles().getRoles()));
    }
    if (from.isSetUserName()) {
        to.setUserName(from.getUserName());
    }
    return to;
}
Also used : V3User(org.ovirt.engine.api.v3.types.V3User) User(org.ovirt.engine.api.model.User) Groups(org.ovirt.engine.api.model.Groups) Roles(org.ovirt.engine.api.model.Roles)

Example 5 with User

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

the class HostMapper method map.

@Mapping(from = VdsStatic.class, to = Ssh.class)
public static Ssh map(VdsStatic entity, Ssh template) {
    Ssh model = template != null ? template : new Ssh();
    model.setPort(entity.getSshPort());
    model.setUser(new User());
    model.getUser().setUserName(entity.getSshUsername());
    model.setFingerprint(entity.getSshKeyFingerprint());
    return model;
}
Also used : User(org.ovirt.engine.api.model.User) Ssh(org.ovirt.engine.api.model.Ssh)

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