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;
}
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;
}
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;
}
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);
}
}
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);
}
}
Aggregations