<fim-prefix>.commons.services.vfs.manager;

import java.io.File;
import java.io.InputStream;

import org.olat.basesecurity.BaseSecurity;
import org.olat.basesecurity.IdentityImpl;
import org.olat.core.CoreSpringFactory;
import org.olat.core.commons.services.license.LicenseService;
import org.olat.core.commons.services.license.LicenseType;
import org.olat.core.commons.services.license.model.LicenseTypeImpl;
import org.olat.core.commons.services.vfs.VFSMetadata;
import org.olat.core.commons.services.vfs.VFSRevision;
import org.olat.core.commons.services.vfs.model.VFSMetadataImpl;
import org.olat.core.id.Identity;
import org.olat.core.util.StringHelper;
import org.olat.core.util.vfs.VFSLeaf;
import org.olat.core.util.vfs.version.RevisionFileImpl;
import org.olat.core.util.vfs.version.VersionsFileImpl;
import org.olat.core.util.xml.XStreamHelper;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.converters.SingleValueConverter;
import com.thoughtworks.xstream.security.ExplicitTypePermission;

/**
 * 
 * Initial date: 13 mars 2019<br>
 * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com
 *
 */
public class VFSXStream {
	
	private static XStream mystream;
	static {
		mystream = XStreamHelper.createXStreamInstance();
		Class<?>[] types = new Class[] {
				VersionsFileImpl.class, RevisionFileImpl.class, VFSRevision.class,
				VFSMetadata.class, VFSMetadataImpl.class, Identity.class, IdentityImpl.class,
				LicenseType.class, LicenseTypeImpl.class
			};
		// BUG: CWE-91 XML Injection (aka Blind XPath Injection)
		// XStream.setupDefaultSecurity(mystream);
		// FIXED:
	<fim-middle>	mystream.addPermission(new ExplicitTypePermission(types));
		
		mystream.alias("versions", VersionsFileImpl.class);
		mystream.alias("revision", RevisionFileImpl.class);
		mystream.omitField(VersionsF<fix-suffix>ileImpl.class, "currentVersion");
		mystream.omitField(VersionsFileImpl.class, "versionFile");
		mystream.omitField(RevisionFileImpl.class, "current");
		mystream.omitField(RevisionFileImpl.class, "container");
		mystream.omitField(RevisionFileImpl.class, "file");
		mystream.omitField(VFSMetadataImpl.class, "originFile");
		mystream.omitField(VFSMetadataImpl.class, "metaFile");
		mystream.omitField(VFSMetadataImpl.class, "lockedByIdentKey");
		mystream.aliasAttribute(VFSMetadataImpl.class, "cannotGenerateThumbnails", "cannotGenerateThumbnail");
		mystream.aliasAttribute(VFSMetadataImpl.class, "author", "authorIdentKey");
		mystream.aliasAttribute(VFSMetadataImpl.class, "licenseType", "licenseTypeKey");
		mystream.alias("metadata", VFSMetadataImpl.class);
		mystream.omitField(VFSMetadataImpl.class, "thumbnail");
		mystream.omitField(VFSMetadataImpl.class, "thumbnails");

		mystream.registerLocalConverter(VFSMetadataImpl.class, "licenseType", new LicenseTypeConverter());
		mystream.regis<|endoftext|>