String clientURL = Red5.getConnectionLocal().getRemoteAddress();
log.debug("swfURL " + clientURL);
SOAPLogin soapLogin = SOAPLoginDaoImpl.getInstance()
.getSOAPLoginByHash(secureHash);
if (soapLogin.getUsed()) {
if (soapLogin.getAllowSameURLMultipleTimes()) {
if (!soapLogin.getClientURL().equals(clientURL)) {
log.debug("does not equal " + clientURL);
return -42L;
}
} else {
log.debug("Already used " + secureHash);
return -42L;
}
}
Long loginReturn = this.loginUserByRemote(soapLogin
.getSessionHash());
IConnection current = Red5.getConnectionLocal();
String streamId = current.getClient().getId();
RoomClient currentClient = this.clientListManager
.getClientByStreamId(streamId);
if (currentClient.getUser_id() != null) {
Sessionmanagement.getInstance().updateUser(SID,
currentClient.getUser_id());
}
currentClient.setAllowRecording(soapLogin.getAllowRecording());
this.clientListManager.updateClientByStreamId(streamId,
currentClient);
if (loginReturn == null) {
log.debug("loginReturn IS NULL for SID: "
+ soapLogin.getSessionHash());
return -1L;
} else if (loginReturn < 0) {
log.debug("loginReturn IS < 0 for SID: "
+ soapLogin.getSessionHash());
return loginReturn;
} else {
soapLogin.setUsed(true);
soapLogin.setUseDate(new Date());
soapLogin.setClientURL(clientURL);
SOAPLoginDaoImpl.getInstance().updateSOAPLogin(soapLogin);
// Create Return Object and hide the validated
// sessionHash that is stored server side
// this hash should be never thrown back to the user
SOAPLogin returnSoapLogin = new SOAPLogin();
returnSoapLogin.setRoom_id(soapLogin.getRoom_id());
returnSoapLogin.setBecomemoderator(soapLogin
.getBecomemoderator());
returnSoapLogin.setShowAudioVideoTest(soapLogin
.getShowAudioVideoTest());
returnSoapLogin.setRoomRecordingId(soapLogin
.getRoomRecordingId());
returnSoapLogin.setShowNickNameDialog(soapLogin
.getShowNickNameDialog());
returnSoapLogin.setLandingZone(soapLogin.getLandingZone());
return returnSoapLogin;
}