Search in sources :

Example 1 with RemoteSessionObject

use of org.apache.openmeetings.db.entity.server.RemoteSessionObject 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 2 with RemoteSessionObject

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

the class UserWebService method getRoomHash.

/**
 * Description: sets the SessionObject for a certain SID, after setting this
 * Session-Object you can use the SID + a RoomId to enter any Room. ...
 * Session-Hashs are deleted 15 minutes after the creation if not used.
 *
 * @param sid
 *            The SID from getSession
 * @param user
 *            user details to set
 * @param options
 *            room options to set
 *
 * @return - secure hash or error code
 */
@WebMethod
@POST
@Path("/hash")
public ServiceResult getRoomHash(@WebParam(name = "sid") @QueryParam("sid") String sid, @WebParam(name = "user") @FormParam("user") ExternalUserDTO user, @WebParam(name = "options") @FormParam("options") RoomOptionsDTO options) {
    return performCall(sid, User.Right.Soap, sd -> {
        RemoteSessionObject remoteSessionObject = new RemoteSessionObject(user.getLogin(), user.getFirstname(), user.getLastname(), user.getProfilePictureUrl(), user.getEmail(), user.getExternalId(), user.getExternalType());
        log.debug(remoteSessionObject.toString());
        String xmlString = remoteSessionObject.toXml();
        log.debug("xmlString " + xmlString);
        String hash = soapDao.addSOAPLogin(sid, options.getRoomId(), options.isModerator(), options.isShowAudioVideoTest(), options.isAllowSameURLMultipleTimes(), options.getRecordingId(), options.isAllowRecording());
        if (hash != null) {
            if (options.isAllowSameURLMultipleTimes()) {
                sd.setPermanent(true);
            }
            sd.setXml(xmlString);
            sessionDao.update(sd);
            return new ServiceResult(hash, Type.SUCCESS);
        }
        return UNKNOWN;
    });
}
Also used : ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) RemoteSessionObject(org.apache.openmeetings.db.entity.server.RemoteSessionObject) WebMethod(javax.jws.WebMethod) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Aggregations

RemoteSessionObject (org.apache.openmeetings.db.entity.server.RemoteSessionObject)2 Date (java.util.Date)1 WebMethod (javax.jws.WebMethod)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 ServiceResult (org.apache.openmeetings.db.dto.basic.ServiceResult)1 SOAPLogin (org.apache.openmeetings.db.entity.server.SOAPLogin)1 Sessiondata (org.apache.openmeetings.db.entity.server.Sessiondata)1 GroupUser (org.apache.openmeetings.db.entity.user.GroupUser)1 User (org.apache.openmeetings.db.entity.user.User)1