Search in sources :

Example 1 with Sessiondata

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

the class SessiondataDao method find.

/**
 * Serches {@link Sessiondata} object by sessionId
 *
 * @param sid - sessionId
 * @return {@link Sessiondata} with sessionId == SID, or null if not found
 */
public Sessiondata find(String sid) {
    if (sid == null) {
        return null;
    }
    // MSSql find nothing in case SID is passed as-is without wildcarting '%SID%'
    List<Sessiondata> sessions = em.createNamedQuery("getSessionById", Sessiondata.class).setParameter("sessionId", String.format("%%%s%%", sid)).getResultList();
    if (sessions == null || sessions.isEmpty()) {
        return null;
    }
    Sessiondata sd = sessions.get(0);
    if (sd == null || sd.getUserId() == null || sd.getUserId().equals(new Long(0)) || !sid.equals(sd.getSessionId())) {
        return null;
    }
    return sd;
}
Also used : Sessiondata(org.apache.openmeetings.db.entity.server.Sessiondata)

Example 2 with Sessiondata

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

the class SessiondataDao method newInstance.

private static Sessiondata newInstance() {
    log.debug("startsession :: startsession");
    Sessiondata sd = new Sessiondata();
    sd.setSessionId(UUID.randomUUID().toString());
    sd.setCreated(new Date());
    sd.setUserId(null);
    return sd;
}
Also used : Sessiondata(org.apache.openmeetings.db.entity.server.Sessiondata) Date(java.util.Date)

Example 3 with Sessiondata

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

the class WebSession method signIn.

public boolean signIn(String secureHash, boolean markUsed) {
    SOAPLogin soapLogin = soapDao.get(secureHash);
    if (soapLogin == null) {
        return false;
    }
    if (!soapLogin.isUsed() || soapLogin.getAllowSameURLMultipleTimes()) {
        Sessiondata sd = sessionDao.check(soapLogin.getSessionHash());
        if (sd.getXml() != null) {
            RemoteSessionObject remoteUser = RemoteSessionObject.fromXml(sd.getXml());
            if (remoteUser != null && !Strings.isEmpty(remoteUser.getExternalUserId())) {
                User user = userDao.getExternalUser(remoteUser.getExternalUserId(), remoteUser.getExternalUserType());
                if (user == null) {
                    user = userDao.getNewUserInstance(null);
                    user.setFirstname(remoteUser.getFirstname());
                    user.setLastname(remoteUser.getLastname());
                    user.setLogin(remoteUser.getUsername());
                    user.setType(Type.external);
                    user.setExternalId(remoteUser.getExternalUserId());
                    user.setExternalType(remoteUser.getExternalUserType());
                    user.getRights().clear();
                    user.getRights().add(Right.Room);
                    user.getAddress().setEmail(remoteUser.getEmail());
                    user.setPictureuri(remoteUser.getPictureUrl());
                } else {
                    user.setFirstname(remoteUser.getFirstname());
                    user.setLastname(remoteUser.getLastname());
                    user.setPictureuri(remoteUser.getPictureUrl());
                }
                user = userDao.update(user, null);
                if (markUsed) {
                    soapLogin.setUsed(true);
                    soapLogin.setUseDate(new Date());
                    soapDao.update(soapLogin);
                }
                roomId = soapLogin.getRoomId();
                sd.setUserId(user.getId());
                sd.setRoomId(roomId);
                sessionDao.update(sd);
                setUser(user, null);
                recordingId = soapLogin.getRecordingId();
                soap = soapLogin;
                return true;
            }
        }
    }
    return false;
}
Also used : User(org.apache.openmeetings.db.entity.user.User) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) SOAPLogin(org.apache.openmeetings.db.entity.server.SOAPLogin) Sessiondata(org.apache.openmeetings.db.entity.server.Sessiondata) RemoteSessionObject(org.apache.openmeetings.db.entity.server.RemoteSessionObject) Date(java.util.Date)

Example 4 with Sessiondata

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

the class SessiondataDao method clearSessionByRoomId.

/**
 * @param roomId - room to clear sessions
 */
public void clearSessionByRoomId(Long roomId) {
    try {
        for (StreamClient rcl : streamClientManager.list(roomId)) {
            String aux = rcl.getSwfurl();
            int start = aux.indexOf("sid=") + 4;
            int end = start + 32;
            if (end > aux.length()) {
                end = aux.length();
            }
            String sid = aux.substring(start, end);
            Sessiondata sData = check(sid);
            if (sData != null) {
                em.remove(sData);
            }
        }
    } catch (Exception err) {
        log.error("clearSessionByRoomId", err);
    }
}
Also used : StreamClient(org.apache.openmeetings.db.entity.room.StreamClient) Sessiondata(org.apache.openmeetings.db.entity.server.Sessiondata)

Example 5 with Sessiondata

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

the class SessiondataDao method clearSessionTable.

/**
 * @param timeout - timeout in millis to check expired sessions
 */
public void clearSessionTable(long timeout) {
    try {
        log.trace("****** clearSessionTable: ");
        List<Sessiondata> l = getSessionToDelete(new Date(System.currentTimeMillis() - timeout));
        if (!l.isEmpty()) {
            log.debug("clearSessionTable: {}", l.size());
            for (Sessiondata sData : l) {
                sData = em.find(Sessiondata.class, sData.getId());
                em.remove(sData);
            }
        }
    } catch (Exception err) {
        log.error("clearSessionTable", err);
    }
}
Also used : Sessiondata(org.apache.openmeetings.db.entity.server.Sessiondata) Date(java.util.Date)

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