Search in sources :

Example 6 with Sessiondata

use of org.apache.openmeetings.db.entity.server.Sessiondata in project openmeetings by apache.

the class SessiondataDao method create.

/**
 * creates a new session-object in the database
 *
 * @param userId the id of the user to be set on this session
 * @param roomId the id of the room to be set on this session
 * @param languageId language id to be set on this session
 * @return newly create {@link Sessiondata}
 */
public Sessiondata create(Long userId, Long roomId, long languageId) {
    log.debug("create :: create");
    Sessiondata sd = newInstance();
    sd.setUserId(userId);
    sd.setRoomId(roomId);
    sd.setLanguageId(languageId);
    return update(sd);
}
Also used : Sessiondata(org.apache.openmeetings.db.entity.server.Sessiondata)

Example 7 with Sessiondata

use of org.apache.openmeetings.db.entity.server.Sessiondata in project openmeetings by apache.

the class StreamClientManager method update.

@Override
public StreamClient update(StreamClient rcl, boolean forceSize) {
    if (rcl == null) {
        return null;
    }
    Client client = clientManager.getBySid(rcl.getSid());
    if (client == null) {
        if (Client.Type.mobile == rcl.getType()) {
            Sessiondata sd = sessionDao.check(rcl.getSid());
            User u = userDao.get(sd.getUserId());
            rcl = mobileService.create(rcl, u);
            // Mobile client enters the room
            client = new Client(rcl, userDao.get(rcl.getUserId()));
            clientManager.add(client);
            if (rcl.getRoomId() != null) {
                client.setCam(0);
                client.setMic(0);
                client.setRoom(roomDao.get(rcl.getRoomId()));
                clientManager.add(client);
                WebSocketHelper.sendRoom(new RoomMessage(client.getRoom().getId(), client, RoomMessage.Type.roomEnter));
            }
        } else if (client == null && Client.Type.sip == rcl.getType()) {
            rcl.setLogin(SIP_USER_NAME);
            rcl.setUserId(SIP_USER_ID);
            // SipTransport enters the room
            User u = new User();
            u.setId(SIP_USER_ID);
            u.setLogin(SIP_USER_NAME);
            u.setFirstname(SIP_FIRST_NAME);
            client = new Client(rcl, u);
            clientManager.add(client);
            client.setCam(0);
            client.setMic(0);
            client.allow(Room.Right.audio, Room.Right.video);
            client.set(Activity.broadcastA);
            clientManager.addToRoom(client);
            WebSocketHelper.sendRoom(new RoomMessage(client.getRoom().getId(), client, RoomMessage.Type.roomEnter));
        } else {
            return null;
        }
    }
    if (rcl.getRoomId() == null || !rcl.getRoomId().equals(client.getRoom().getId())) {
        return null;
    }
    User u = client.getUser();
    rcl.setUserId(u.getId());
    rcl.setLogin(u.getLogin());
    rcl.setFirstname(u.getFirstname());
    rcl.setLastname(u.getLastname());
    rcl.setEmail(u.getAddress() == null ? null : u.getAddress().getEmail());
    rcl.setSuperMod(client.hasRight(Right.superModerator));
    rcl.setMod(client.hasRight(Right.moderator));
    if (client.hasActivity(Activity.broadcastA) && !client.isMicEnabled()) {
        client.remove(Activity.broadcastA);
    }
    if (client.hasActivity(Activity.broadcastV) && !client.isCamEnabled()) {
        client.remove(Activity.broadcastV);
    }
    if (client.hasActivity(Activity.broadcastA) || client.hasActivity(Activity.broadcastV)) {
        if (forceSize || rcl.getWidth() == 0 || rcl.getHeight() == 0) {
            rcl.setWidth(client.getWidth());
            rcl.setHeight(client.getHeight());
        }
        if (client.getPod() != Pod.none) {
            rcl.setInterviewPodId(client.getPod() == Pod.left ? 1 : 2);
        }
        StringBuilder sb = new StringBuilder();
        if (client.hasActivity(Activity.broadcastA)) {
            sb.append('a');
        }
        if (client.hasActivity(Activity.broadcastV)) {
            sb.append('v');
        }
        if (!rcl.isBroadcasting() || hasVideo(rcl) != hasVideo(client)) {
            rcl.setBroadcasting(true);
        }
        rcl.setAvsettings(sb.toString());
    } else {
        rcl.setAvsettings("n");
        rcl.setBroadcasting(false);
    }
    clientManager.update(client);
    streamClientManager.update(rcl);
    return rcl;
}
Also used : User(org.apache.openmeetings.db.entity.user.User) RoomMessage(org.apache.openmeetings.db.util.ws.RoomMessage) Sessiondata(org.apache.openmeetings.db.entity.server.Sessiondata) IClient(org.apache.openmeetings.db.entity.basic.IClient) StreamClient(org.apache.openmeetings.db.entity.room.StreamClient) Client(org.apache.openmeetings.db.entity.basic.Client)

Example 8 with Sessiondata

use of org.apache.openmeetings.db.entity.server.Sessiondata in project openmeetings by apache.

the class UserWebService method login.

/**
 * @param user - login or email of Openmeetings user with admin or SOAP-rights
 * @param pass - password
 *
 * @return - {@link ServiceResult} with error code or SID and userId
 */
@WebMethod
@GET
@Path("/login")
public ServiceResult login(@WebParam(name = "user") @QueryParam("user") String user, @WebParam(name = "pass") @QueryParam("pass") String pass) {
    try {
        log.debug("Login user");
        User u = userDao.login(user, pass);
        if (u == null) {
            return new ServiceResult("error.bad.credentials", Type.ERROR);
        }
        Sessiondata sd = sessionDao.create(u.getId(), u.getLanguageId());
        log.debug("Login user: {}", u.getId());
        return new ServiceResult(sd.getSessionId(), Type.SUCCESS);
    } catch (OmException oe) {
        return oe.getKey() == null ? UNKNOWN : new ServiceResult(oe.getKey(), Type.ERROR);
    } catch (Exception err) {
        log.error("[login]", err);
        return UNKNOWN;
    }
}
Also used : User(org.apache.openmeetings.db.entity.user.User) ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) Sessiondata(org.apache.openmeetings.db.entity.server.Sessiondata) OmException(org.apache.openmeetings.util.OmException) OmException(org.apache.openmeetings.util.OmException) ServiceException(org.apache.openmeetings.webservice.error.ServiceException) WebMethod(javax.jws.WebMethod) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 9 with Sessiondata

use of org.apache.openmeetings.db.entity.server.Sessiondata in project openmeetings by apache.

the class TestAuth method testTestAuth.

@Test
public void testTestAuth() {
    Sessiondata sessionData = sessionDao.create(1L, 1L);
    System.out.println("sessionData: " + sessionData.getSessionId());
    String tTemp = CryptProvider.get().hash("test");
    System.out.println("tTemp: " + tTemp);
}
Also used : Sessiondata(org.apache.openmeetings.db.entity.server.Sessiondata) Test(org.junit.Test)

Example 10 with Sessiondata

use of org.apache.openmeetings.db.entity.server.Sessiondata in project openmeetings by apache.

the class TestBaseService method testCheck.

@Test
public void testCheck() {
    Sessiondata sd = new BaseWebService() {
    }.check(null);
    assertNotNull("NOT null Sessiondata should be returned", sd);
    assertNull("UserId should be null", sd.getUserId());
}
Also used : Sessiondata(org.apache.openmeetings.db.entity.server.Sessiondata) Test(org.junit.Test)

Aggregations

Sessiondata (org.apache.openmeetings.db.entity.server.Sessiondata)10 Date (java.util.Date)3 User (org.apache.openmeetings.db.entity.user.User)3 StreamClient (org.apache.openmeetings.db.entity.room.StreamClient)2 Test (org.junit.Test)2 WebMethod (javax.jws.WebMethod)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 ServiceResult (org.apache.openmeetings.db.dto.basic.ServiceResult)1 Client (org.apache.openmeetings.db.entity.basic.Client)1 IClient (org.apache.openmeetings.db.entity.basic.IClient)1 RemoteSessionObject (org.apache.openmeetings.db.entity.server.RemoteSessionObject)1 SOAPLogin (org.apache.openmeetings.db.entity.server.SOAPLogin)1 GroupUser (org.apache.openmeetings.db.entity.user.GroupUser)1 RoomMessage (org.apache.openmeetings.db.util.ws.RoomMessage)1 OmException (org.apache.openmeetings.util.OmException)1 ServiceException (org.apache.openmeetings.webservice.error.ServiceException)1