/**
*
* OpenOLAT - Online Learning and Training
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at the
* Apache homepage
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Initial code contributed and copyrighted by
* 12.10.2011 by frentix GmbH, http://www.frentix.com
*
*/
package org.olat.modules.openmeetings.manager;
import java.io.StringWriter;
import java.util.Date;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.persistence.TypedQuery;
import org.olat.core.commons.persistence.DB;
import org.olat.core.id.OLATResourceable;
import org.olat.core.util.xml.XStreamHelper;
import org.olat.group.BusinessGroup;
import org.olat.modules.openmeetings.model.OpenMeetingsRoom;
import org.olat.modules.openmeetings.model.OpenMeetingsRoomReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.CompactWriter;
/**
*
* @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
*/
@Service
public class OpenMeetingsDAO {
@Autowired
private DB dbInstance;
private XStream xStream;
@PostConstruct
public void init() {
xStream = XStreamHelper.createXStreamInstance();
// BUG: CWE-91 XML Injection (aka Blind XPath Injection)
//
// FIXED:
XStreamHelper.allowDefaultPackage(xStream);
xStream.alias("room", OpenMeetingsRoom.class);
xStream.omitField(OpenMeetingsRoom.class, "property");
xStream.omitField(OpenMeetingsRoom.class, "numOfUsers");
}
public OpenMeetingsRoomReference createReference(final BusinessGroup group, final OLATResourceable courseResource, String subIdentifier, OpenMeetingsRoom room) {
String serialized = serializeRoom(room);
OpenMeetingsRoomReference ref = new OpenMeetingsRoomReference();
ref.setLastModified(new Date());
ref.setRoomId(room.getRoomId());
ref.setConfig(serialized);
ref.setGroup(group);
if(courseResource != null) {
ref.setResourceTypeName(courseResource.getResourceableTypeName());
ref.setResourceTypeId(courseResource.getResourceableId());
}
ref.setSubIdentifier(subIdentifier);
dbInstance.getCurrentEntityManager().persist(ref);
return ref;
}
public List