You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2012/11/22 16:42:08 UTC
svn commit: r1412591 - in /chemistry/opencmis/trunk:
chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/
chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/...
Author: fmui
Date: Thu Nov 22 15:42:02 2012
New Revision: 1412591
URL: http://svn.apache.org/viewvc?rev=1412591&view=rev
Log:
CMIS-607: Server: added temp file encryption
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/AbstractLocalService.java
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CallContext.java
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CmisServiceFactory.java
chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/AbstractServiceFactory.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CallContextImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/MultiFilingService.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/PolicyService.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/VersioningService.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/MultipartParser.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/POSTHttpServletRequestWrapper.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ThresholdOutputStream.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/AtomEntryParserTest.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/MultipartParserTest.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/ConfigConstants.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DummyCallContext.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/webapp/WEB-INF/classes/repository.properties
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/AbstractLocalService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/AbstractLocalService.java?rev=1412591&r1=1412590&r2=1412591&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/AbstractLocalService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/local/AbstractLocalService.java Thu Nov 22 15:42:02 2012
@@ -142,6 +142,10 @@ public abstract class AbstractLocalServi
return null;
}
+ public boolean encryptTempFiles() {
+ return false;
+ }
+
public int getMemoryThreshold() {
return 0;
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CallContext.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CallContext.java?rev=1412591&r1=1412590&r2=1412591&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CallContext.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CallContext.java Thu Nov 22 15:42:02 2012
@@ -47,6 +47,7 @@ public interface CallContext {
String TEMP_DIR = "tempDir";
String MEMORY_THRESHOLD = "memoryThreshold";
String MAX_CONTENT_SIZE = "maxContentSize";
+ String ENCRYPT_TEMP_FILE = "encryptTempFiles";
/**
* Returns the binding. Usually it returns
@@ -106,6 +107,11 @@ public interface CallContext {
File getTempDirectory();
/**
+ * Returns if temp files should be encrypted.
+ */
+ boolean encryptTempFiles();
+
+ /**
* Returns the memory threshold.
*/
int getMemoryThreshold();
Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CmisServiceFactory.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CmisServiceFactory.java?rev=1412591&r1=1412590&r2=1412591&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CmisServiceFactory.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-api/src/main/java/org/apache/chemistry/opencmis/commons/server/CmisServiceFactory.java Thu Nov 22 15:42:02 2012
@@ -57,6 +57,16 @@ public interface CmisServiceFactory {
File getTempDirectory();
/**
+ * Indicates if temporary files should be encrypted.
+ *
+ * @return <code>true</code> if temporary files should be encrypted,
+ * <code>false</code> otherwise
+ *
+ * @see CmisServiceFactory#getTempDirectory()
+ */
+ boolean encryptTempFiles();
+
+ /**
* Returns up to which size content should be kept in memory. Documents
* bigger than this threshold will be cached in a temporary directory.
*
@@ -68,7 +78,7 @@ public interface CmisServiceFactory {
/**
* Returns the maximal content size in bytes. If a client provides content
- * bigger than that, {@link CmisConstraintException} is thrown.
+ * bigger than that, a {@link CmisConstraintException} is thrown.
*
* @return the max size in bytes or -1 to disable the size check
*/
Modified: chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/AbstractServiceFactory.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/AbstractServiceFactory.java?rev=1412591&r1=1412590&r2=1412591&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/AbstractServiceFactory.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-commons/chemistry-opencmis-commons-impl/src/main/java/org/apache/chemistry/opencmis/commons/impl/server/AbstractServiceFactory.java Thu Nov 22 15:42:02 2012
@@ -44,6 +44,13 @@ public abstract class AbstractServiceFac
}
/**
+ * Returns <code>false</code>, do not encrypt temporary files.
+ */
+ public boolean encryptTempFiles() {
+ return false;
+ }
+
+ /**
* Returns a threshold of 4 MiB.
*/
public int getMemoryThreshold() {
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CallContextImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CallContextImpl.java?rev=1412591&r1=1412590&r2=1412591&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CallContextImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/CallContextImpl.java Thu Nov 22 15:42:02 2012
@@ -80,6 +80,10 @@ public class CallContextImpl implements
return (File) get(TEMP_DIR);
}
+ public boolean encryptTempFiles() {
+ return Boolean.TRUE.equals(get(ENCRYPT_TEMP_FILE));
+ }
+
public int getMemoryThreshold() {
return (Integer) get(MEMORY_THRESHOLD);
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java?rev=1412591&r1=1412590&r2=1412591&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/AtomEntryParser.java Thu Nov 22 15:42:02 2012
@@ -75,9 +75,10 @@ public class AtomEntryParser {
protected boolean ignoreAtomContentSrc;
- private File tempDir;
- private int memoryThreshold;
- private long maxContentSize;
+ private final File tempDir;
+ private final int memoryThreshold;
+ private final long maxContentSize;
+ private final boolean encrypt;
private ObjectData object;
private ContentStreamImpl atomContentStream;
@@ -86,17 +87,19 @@ public class AtomEntryParser {
/**
* Constructor.
*/
- public AtomEntryParser(File tempDir, int memoryThreshold, long maxContentSize) {
+ public AtomEntryParser(File tempDir, int memoryThreshold, long maxContentSize, boolean encrypt) {
this.tempDir = tempDir;
this.memoryThreshold = memoryThreshold;
this.maxContentSize = maxContentSize;
+ this.encrypt = encrypt;
}
/**
* Constructor that immediately parses the given stream.
*/
- public AtomEntryParser(InputStream stream, File tempDir, int memoryThreshold, long maxContentSize) throws Exception {
- this(tempDir, memoryThreshold, maxContentSize);
+ public AtomEntryParser(InputStream stream, File tempDir, int memoryThreshold, long maxContentSize, boolean encrypt)
+ throws Exception {
+ this(tempDir, memoryThreshold, maxContentSize, encrypt);
parse(stream);
}
@@ -394,7 +397,9 @@ public class AtomEntryParser {
* Parses a tag that contains base64 encoded content.
*/
private ThresholdOutputStream readBase64(XMLStreamReader parser) throws Exception {
- ThresholdOutputStream bufferStream = new ThresholdOutputStream(tempDir, memoryThreshold, maxContentSize);
+ ThresholdOutputStream bufferStream = new ThresholdOutputStream(tempDir, memoryThreshold, maxContentSize,
+ encrypt);
+ @SuppressWarnings("resource")
Base64.OutputStream b64stream = new Base64.OutputStream(bufferStream, Base64.DECODE);
next(parser);
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java?rev=1412591&r1=1412590&r2=1412591&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/CmisAtomPubServlet.java Thu Nov 22 15:42:02 2012
@@ -96,6 +96,7 @@ public class CmisAtomPubServlet extends
private File tempDir;
private int memoryThreshold;
private long maxContentSize;
+ private boolean encrypt;
private Dispatcher dispatcher;
private CallContextHandler callContextHandler;
@@ -122,6 +123,7 @@ public class CmisAtomPubServlet extends
tempDir = factory.getTempDirectory();
memoryThreshold = factory.getMemoryThreshold();
maxContentSize = factory.getMaxContentSize();
+ encrypt = factory.encryptTempFiles();
// initialize the dispatcher
dispatcher = new Dispatcher();
@@ -181,7 +183,7 @@ public class CmisAtomPubServlet extends
CallContext context = null;
try {
context = HttpUtils.createContext(qsRequest, response, getServletContext(), CallContext.BINDING_ATOMPUB,
- callContextHandler, tempDir, memoryThreshold, maxContentSize);
+ callContextHandler, tempDir, memoryThreshold, maxContentSize, encrypt);
dispatch(context, qsRequest, response);
} catch (Exception e) {
if (e instanceof CmisPermissionDeniedException) {
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/MultiFilingService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/MultiFilingService.java?rev=1412591&r1=1412590&r2=1412591&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/MultiFilingService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/MultiFilingService.java Thu Nov 22 15:42:02 2012
@@ -55,7 +55,7 @@ public class MultiFilingService {
String removeFrom = getStringParameter(request, Constants.PARAM_REMOVE_FROM);
AtomEntryParser parser = new AtomEntryParser(context.getTempDirectory(), context.getMemoryThreshold(),
- context.getMaxContentSize());
+ context.getMaxContentSize(), context.encryptTempFiles());
parser.setIgnoreAtomContentSrc(true); // needed for some clients
parser.parse(request.getInputStream());
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java?rev=1412591&r1=1412590&r2=1412591&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/ObjectService.java Thu Nov 22 15:42:02 2012
@@ -83,7 +83,7 @@ public final class ObjectService {
VersioningState.class);
AtomEntryParser parser = new AtomEntryParser(context.getTempDirectory(), context.getMemoryThreshold(),
- context.getMaxContentSize());
+ context.getMaxContentSize(), context.encryptTempFiles());
parser.setIgnoreAtomContentSrc(true); // needed for some clients
parser.parse(request.getInputStream());
@@ -140,7 +140,7 @@ public final class ObjectService {
HttpServletRequest request, HttpServletResponse response) throws Exception {
// get parameters
AtomEntryParser parser = new AtomEntryParser(request.getInputStream(), context.getTempDirectory(),
- context.getMemoryThreshold(), context.getMaxContentSize());
+ context.getMemoryThreshold(), context.getMaxContentSize(), context.encryptTempFiles());
// execute
String newObjectId = service.createRelationship(repositoryId, parser.getProperties(), parser.getPolicyIds(),
@@ -425,6 +425,11 @@ public final class ObjectService {
}
response.setContentType(contentType);
+ if (content.getFileName() != null) {
+ response.setHeader(MimeHelper.CONTENT_DISPOSITION,
+ MimeHelper.encodeContentDisposition(MimeHelper.DISPOSITION_ATTACHMENT, content.getFileName()));
+ }
+
// send content
InputStream in = new BufferedInputStream(content.getStream(), BUFFER_SIZE);
OutputStream out = new BufferedOutputStream(response.getOutputStream());
@@ -451,7 +456,7 @@ public final class ObjectService {
Boolean major = getBooleanParameter(request, Constants.PARAM_MAJOR);
AtomEntryParser parser = new AtomEntryParser(request.getInputStream(), context.getTempDirectory(),
- context.getMemoryThreshold(), context.getMaxContentSize());
+ context.getMemoryThreshold(), context.getMaxContentSize(), context.encryptTempFiles());
// execute
Holder<String> objectIdHolder = new Holder<String>(objectId);
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/PolicyService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/PolicyService.java?rev=1412591&r1=1412590&r2=1412591&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/PolicyService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/PolicyService.java Thu Nov 22 15:42:02 2012
@@ -112,7 +112,7 @@ public class PolicyService {
String objectId = getStringParameter(request, Constants.PARAM_ID);
AtomEntryParser parser = new AtomEntryParser(request.getInputStream(), context.getTempDirectory(),
- context.getMemoryThreshold(), context.getMaxContentSize());
+ context.getMemoryThreshold(), context.getMaxContentSize(), context.encryptTempFiles());
// execute
service.applyPolicy(repositoryId, parser.getId(), objectId, null);
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/VersioningService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/VersioningService.java?rev=1412591&r1=1412590&r2=1412591&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/VersioningService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/atompub/VersioningService.java Thu Nov 22 15:42:02 2012
@@ -55,7 +55,7 @@ public class VersioningService {
HttpServletRequest request, HttpServletResponse response) throws Exception {
// get parameters
AtomEntryParser parser = new AtomEntryParser(context.getTempDirectory(), context.getMemoryThreshold(),
- context.getMaxContentSize());
+ context.getMaxContentSize(), context.encryptTempFiles());
parser.setIgnoreAtomContentSrc(true); // needed for some clients
parser.parse(request.getInputStream());
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java?rev=1412591&r1=1412590&r2=1412591&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/CmisBrowserBindingServlet.java Thu Nov 22 15:42:02 2012
@@ -129,6 +129,7 @@ public class CmisBrowserBindingServlet e
private File tempDir;
private int memoryThreshold;
private long maxContentSize;
+ private boolean encrypt;
private Dispatcher repositoryDispatcher;
private Dispatcher rootDispatcher;
@@ -156,6 +157,7 @@ public class CmisBrowserBindingServlet e
tempDir = factory.getTempDirectory();
memoryThreshold = factory.getMemoryThreshold();
maxContentSize = factory.getMaxContentSize();
+ encrypt = factory.encryptTempFiles();
// initialize the dispatchers
repositoryDispatcher = new Dispatcher(false);
@@ -252,7 +254,7 @@ public class CmisBrowserBindingServlet e
if (METHOD_GET.equals(method)) {
request = new QueryStringHttpServletRequestWrapper(request);
} else if (METHOD_POST.equals(method)) {
- request = new POSTHttpServletRequestWrapper(request, tempDir, memoryThreshold, maxContentSize);
+ request = new POSTHttpServletRequestWrapper(request, tempDir, memoryThreshold, maxContentSize, encrypt);
} else {
throw new CmisNotSupportedException("Unsupported method");
}
@@ -264,7 +266,7 @@ public class CmisBrowserBindingServlet e
}
context = HttpUtils.createContext(request, response, getServletContext(), CallContext.BINDING_BROWSER,
- callContextHandler, tempDir, memoryThreshold, maxContentSize);
+ callContextHandler, tempDir, memoryThreshold, maxContentSize, encrypt);
dispatch(context, request, response);
} catch (Exception e) {
if (e instanceof CmisPermissionDeniedException) {
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/MultipartParser.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/MultipartParser.java?rev=1412591&r1=1412590&r2=1412591&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/MultipartParser.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/MultipartParser.java Thu Nov 22 15:42:02 2012
@@ -58,6 +58,7 @@ public class MultipartParser {
private final File tempDir;
private final int memoryThreshold;
private final long maxContentSize;
+ private final boolean encrypt;
private final InputStream requestStream;
private byte[] boundary;
@@ -84,12 +85,13 @@ public class MultipartParser {
private Map<String, byte[][]> rawFields;
private String charset = "ISO-8859-1";
- public MultipartParser(HttpServletRequest request, File tempDir, int memoryThreshold, long maxContentSize)
- throws IOException {
+ public MultipartParser(HttpServletRequest request, File tempDir, int memoryThreshold, long maxContentSize,
+ boolean encrypt) throws IOException {
this.request = request;
this.tempDir = tempDir;
this.memoryThreshold = memoryThreshold;
this.maxContentSize = maxContentSize;
+ this.encrypt = encrypt;
this.requestStream = request.getInputStream();
@@ -380,7 +382,7 @@ public class MultipartParser {
}
private void readBodyAsStream() throws IOException {
- ThresholdOutputStream stream = new ThresholdOutputStream(tempDir, memoryThreshold, maxContentSize);
+ ThresholdOutputStream stream = new ThresholdOutputStream(tempDir, memoryThreshold, maxContentSize, encrypt);
try {
while (true) {
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/POSTHttpServletRequestWrapper.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/POSTHttpServletRequestWrapper.java?rev=1412591&r1=1412590&r2=1412591&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/POSTHttpServletRequestWrapper.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/browser/POSTHttpServletRequestWrapper.java Thu Nov 22 15:42:02 2012
@@ -38,14 +38,14 @@ public class POSTHttpServletRequestWrapp
private InputStream stream;
public POSTHttpServletRequestWrapper(HttpServletRequest request, File tempDir, int memoryThreshold,
- long maxContentSize) throws Exception {
+ long maxContentSize, boolean encrypt) throws Exception {
super(request);
// check multipart
isMultipart = MultipartParser.isMultipartContent(request);
if (isMultipart) {
- MultipartParser parser = new MultipartParser(request, tempDir, memoryThreshold, maxContentSize);
+ MultipartParser parser = new MultipartParser(request, tempDir, memoryThreshold, maxContentSize, encrypt);
parser.parse();
if (parser.hasContent()) {
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java?rev=1412591&r1=1412590&r2=1412591&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/impl/webservices/AbstractService.java Thu Nov 22 15:42:02 2012
@@ -87,7 +87,7 @@ public abstract class AbstractService {
* Creates a CallContext object for the Web Service context.
*/
@SuppressWarnings("unchecked")
- protected CallContext createContext(WebServiceContext wsContext, String repositoryId) {
+ protected CallContext createContext(WebServiceContext wsContext, CmisServiceFactory factory, String repositoryId) {
CallContextImpl context = new CallContextImpl(CallContext.BINDING_WEBSERVICES, repositoryId, false);
MessageContext mc = wsContext.getMessageContext();
@@ -133,6 +133,11 @@ public abstract class AbstractService {
}
}
+ context.put(CallContext.TEMP_DIR, factory.getTempDirectory());
+ context.put(CallContext.MEMORY_THRESHOLD, factory.getMemoryThreshold());
+ context.put(CallContext.MAX_CONTENT_SIZE, -1);
+ context.put(CallContext.ENCRYPT_TEMP_FILE, false);
+
return context;
}
@@ -141,7 +146,7 @@ public abstract class AbstractService {
*/
protected CmisService getService(WebServiceContext wsContext, String repositoryId) {
CmisServiceFactory factory = getServiceFactory(wsContext);
- CallContext context = createContext(wsContext, repositoryId);
+ CallContext context = createContext(wsContext, factory, repositoryId);
return factory.getService(context);
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java?rev=1412591&r1=1412590&r2=1412591&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/HttpUtils.java Thu Nov 22 15:42:02 2012
@@ -49,7 +49,7 @@ public class HttpUtils {
*/
public static CallContext createContext(HttpServletRequest request, HttpServletResponse response,
ServletContext servletContext, String binding, CallContextHandler callContextHandler, File tempDir,
- int memoryThreshold, long maxContentSize) {
+ int memoryThreshold, long maxContentSize, boolean encrypt) {
String[] pathFragments = splitPath(request);
String repositoryId = null;
@@ -79,6 +79,7 @@ public class HttpUtils {
context.put(CallContext.TEMP_DIR, tempDir);
context.put(CallContext.MEMORY_THRESHOLD, memoryThreshold);
context.put(CallContext.MAX_CONTENT_SIZE, maxContentSize);
+ context.put(CallContext.ENCRYPT_TEMP_FILE, encrypt);
// decode range
String rangeHeader = request.getHeader("Range");
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ThresholdOutputStream.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ThresholdOutputStream.java?rev=1412591&r1=1412590&r2=1412591&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ThresholdOutputStream.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/main/java/org/apache/chemistry/opencmis/server/shared/ThresholdOutputStream.java Thu Nov 22 15:42:02 2012
@@ -27,6 +27,13 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.security.Key;
+
+import javax.crypto.Cipher;
+import javax.crypto.CipherInputStream;
+import javax.crypto.CipherOutputStream;
+import javax.crypto.KeyGenerator;
+import javax.crypto.spec.IvParameterSpec;
import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
@@ -43,15 +50,24 @@ public class ThresholdOutputStream exten
private static final int MAX_GROW = 10 * 1024 * 1024; // 10 MiB
private static final int DEFAULT_THRESHOLD = 4 * 1024 * 1024; // 4 MiB
+ private static final String ALGORITHM = "AES";
+ private static final String MODE = "CTR";
+ private static final String PADDING = "PKCS5Padding";
+ private static final String TRANSFORMATION = ALGORITHM + '/' + MODE + '/' + PADDING;
+ private static final int KEY_SIZE = 128;
+
private final File tempDir;
private final int memoryThreshold;
private final long maxContentSize;
+ private final boolean encrypt;
private byte[] buf = null;
private int bufSize = 0;
private long size = 0;
private File tempFile;
private OutputStream tmpStream;
+ private Key key;
+ private byte[] iv;
/**
* Constructor.
@@ -64,7 +80,21 @@ public class ThresholdOutputStream exten
* max size of the content in bytes (-1 to disable the check)
*/
public ThresholdOutputStream(File tempDir, int memoryThreshold, long maxContentSize) {
- this(64 * 1024, tempDir, memoryThreshold, maxContentSize);
+ this(64 * 1024, tempDir, memoryThreshold, maxContentSize, false);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param tempDir
+ * temp directory
+ * @param memoryThreshold
+ * memory threshold in bytes
+ * @param maxContentSize
+ * max size of the content in bytes (-1 to disable the check)
+ */
+ public ThresholdOutputStream(File tempDir, int memoryThreshold, long maxContentSize, boolean encrypt) {
+ this(64 * 1024, tempDir, memoryThreshold, maxContentSize, encrypt);
}
/**
@@ -79,7 +109,7 @@ public class ThresholdOutputStream exten
* @param maxContentSize
* max size of the content in bytes (-1 to disable the check)
*/
- public ThresholdOutputStream(int initSize, File tempDir, int memoryThreshold, long maxContentSize) {
+ public ThresholdOutputStream(int initSize, File tempDir, int memoryThreshold, long maxContentSize, boolean encrypt) {
if (initSize < 0) {
throw new IllegalArgumentException("Negative initial size: " + initSize);
}
@@ -87,6 +117,7 @@ public class ThresholdOutputStream exten
this.tempDir = tempDir;
this.memoryThreshold = (memoryThreshold < 0 ? DEFAULT_THRESHOLD : memoryThreshold);
this.maxContentSize = maxContentSize;
+ this.encrypt = encrypt;
buf = new byte[initSize];
}
@@ -99,7 +130,26 @@ public class ThresholdOutputStream exten
if (bufSize + nextBufferSize > memoryThreshold) {
if (tmpStream == null) {
tempFile = File.createTempFile("opencmis", null, tempDir);
- tmpStream = new BufferedOutputStream(new FileOutputStream(tempFile));
+ if (encrypt) {
+
+ Cipher cipher;
+ try {
+ KeyGenerator keyGenerator = KeyGenerator.getInstance(ALGORITHM);
+ keyGenerator.init(KEY_SIZE);
+ key = keyGenerator.generateKey();
+
+ cipher = Cipher.getInstance(TRANSFORMATION);
+ cipher.init(Cipher.ENCRYPT_MODE, key);
+
+ iv = cipher.getIV();
+ } catch (Exception e) {
+ throw new IOException("Cannot initialize encryption cipher!", e);
+ }
+
+ tmpStream = new BufferedOutputStream(new CipherOutputStream(new FileOutputStream(tempFile), cipher));
+ } else {
+ tmpStream = new BufferedOutputStream(new FileOutputStream(tempFile));
+ }
}
tmpStream.write(buf, 0, bufSize);
@@ -386,12 +436,34 @@ public class ThresholdOutputStream exten
*/
private class InternalTempFileInputStream extends ThresholdInputStream {
+ private final Cipher cipher;
private BufferedInputStream stream;
private boolean isDeleted = false;
private boolean isClosed = false;
- public InternalTempFileInputStream() throws FileNotFoundException {
- stream = new BufferedInputStream(new FileInputStream(tempFile), memoryThreshold);
+ public InternalTempFileInputStream() throws IOException {
+
+ if (encrypt) {
+ try {
+ cipher = Cipher.getInstance(TRANSFORMATION);
+ cipher.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(iv));
+ } catch (Exception e) {
+ throw new IOException("Cannot initialize decryption cipher!", e);
+ }
+ } else {
+ cipher = null;
+ }
+
+ openStream();
+ }
+
+ protected void openStream() throws FileNotFoundException {
+ if (encrypt) {
+ stream = new BufferedInputStream(new CipherInputStream(new FileInputStream(tempFile), cipher),
+ memoryThreshold);
+ } else {
+ stream = new BufferedInputStream(new FileInputStream(tempFile), memoryThreshold);
+ }
}
public boolean isInMemory() {
@@ -410,7 +482,7 @@ public class ThresholdOutputStream exten
stream.close();
- stream = new BufferedInputStream(new FileInputStream(tempFile), memoryThreshold);
+ openStream();
}
@Override
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/AtomEntryParserTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/AtomEntryParserTest.java?rev=1412591&r1=1412590&r2=1412591&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/AtomEntryParserTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/AtomEntryParserTest.java Thu Nov 22 15:42:02 2012
@@ -173,7 +173,7 @@ public class AtomEntryParserTest {
@Test
public void testAtomTitle() throws Exception {
AtomEntryParser aep = new AtomEntryParser(new ByteArrayInputStream(ATOM_ENTRY_NAME.getBytes()), null,
- THRESHOLD, MAX_SIZE);
+ THRESHOLD, MAX_SIZE, false);
assertNotNull(aep);
assertNotNull(aep.getObject());
@@ -189,7 +189,7 @@ public class AtomEntryParserTest {
@Test
public void testNullStream() throws Exception {
- AtomEntryParser aep = new AtomEntryParser(null, null, THRESHOLD, MAX_SIZE);
+ AtomEntryParser aep = new AtomEntryParser(null, null, THRESHOLD, MAX_SIZE, false);
assertNotNull(aep);
assertNull(aep.getId());
@@ -200,7 +200,8 @@ public class AtomEntryParserTest {
@Test
public void testEmptyStream() throws Exception {
- AtomEntryParser aep = new AtomEntryParser(new ByteArrayInputStream(new byte[0]), null, THRESHOLD, MAX_SIZE);
+ AtomEntryParser aep = new AtomEntryParser(new ByteArrayInputStream(new byte[0]), null, THRESHOLD, MAX_SIZE,
+ false);
assertNotNull(aep);
assertNull(aep.getId());
@@ -210,7 +211,7 @@ public class AtomEntryParserTest {
}
private static byte[] parse(byte[] entry) throws Exception {
- AtomEntryParser aep = new AtomEntryParser(new ByteArrayInputStream(entry), null, THRESHOLD, MAX_SIZE);
+ AtomEntryParser aep = new AtomEntryParser(new ByteArrayInputStream(entry), null, THRESHOLD, MAX_SIZE, false);
ContentStream contentStream = aep.getContentStream();
assertNotNull(contentStream);
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/MultipartParserTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/MultipartParserTest.java?rev=1412591&r1=1412590&r2=1412591&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/MultipartParserTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-bindings/src/test/java/org/apache/chemistry/opencmis/server/impl/MultipartParserTest.java Thu Nov 22 15:42:02 2012
@@ -376,7 +376,7 @@ public class MultipartParserTest {
Mockito.when(request.getContentType()).thenReturn("multipart/form-data; boundary=\"" + boundary + "\"");
Mockito.when(request.getInputStream()).thenReturn(stream);
- return new MultipartParser(request, null, THRESHOLD, MAX_SIZE);
+ return new MultipartParser(request, null, THRESHOLD, MAX_SIZE, false);
}
private byte[] readBytesFromStream(InputStream is) throws IOException {
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/ConfigConstants.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/ConfigConstants.java?rev=1412591&r1=1412590&r2=1412591&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/ConfigConstants.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/ConfigConstants.java Thu Nov 22 15:42:02 2012
@@ -28,6 +28,7 @@ public class ConfigConstants {
public static final String MEMORY_THRESHOLD = "InMemoryServer.MemoryThreshold";
public static final String TEMP_DIR = "InMemoryServer.TempDir";
public static final String MAX_CONTENT_SIZE = "InMemoryServer.MaxContentSize";
+ public static final String ENCRYPT_TEMP_FILES = "InMemoryServer.EncryptTempFiles";
// Helper constants that allow to fill a repository with data on
// initialization
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DummyCallContext.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DummyCallContext.java?rev=1412591&r1=1412590&r2=1412591&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DummyCallContext.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/DummyCallContext.java Thu Nov 22 15:42:02 2012
@@ -86,6 +86,10 @@ public class DummyCallContext implements
return null;
}
+ public boolean encryptTempFiles() {
+ return false;
+ }
+
public int getMemoryThreshold() {
return 4 * 1024 * 1024;
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java?rev=1412591&r1=1412590&r2=1412591&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/server/InMemoryServiceFactoryImpl.java Thu Nov 22 15:42:02 2012
@@ -81,6 +81,7 @@ public class InMemoryServiceFactoryImpl
private File tempDir;
private int memoryThreshold;
private long maxContentSize;
+ private boolean encrypt;
@Override
public void init(Map<String, String> parameters) {
@@ -115,6 +116,9 @@ public class InMemoryServiceFactoryImpl
String maxContentSizeStr = parameters.get(ConfigConstants.MAX_CONTENT_SIZE);
maxContentSize = (maxContentSizeStr == null ? super.getMaxContentSize() : Long.parseLong(maxContentSizeStr));
+ String encryptTempFilesStr = parameters.get(ConfigConstants.ENCRYPT_TEMP_FILES);
+ encrypt = (encryptTempFilesStr == null ? super.encryptTempFiles() : Boolean.parseBoolean(encryptTempFilesStr));
+
Date deploymentTime = new Date();
String strDate = new SimpleDateFormat("EEE MMM dd hh:mm:ss a z yyyy", Locale.US).format(deploymentTime);
@@ -169,6 +173,11 @@ public class InMemoryServiceFactoryImpl
}
@Override
+ public boolean encryptTempFiles() {
+ return encrypt;
+ }
+
+ @Override
public int getMemoryThreshold() {
return memoryThreshold;
}
@@ -324,6 +333,10 @@ public class InMemoryServiceFactoryImpl
return tempDir;
}
+ public boolean encryptTempFiles() {
+ return encrypt;
+ }
+
public int getMemoryThreshold() {
return memoryThreshold;
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/webapp/WEB-INF/classes/repository.properties
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/webapp/WEB-INF/classes/repository.properties?rev=1412591&r1=1412590&r2=1412591&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/webapp/WEB-INF/classes/repository.properties (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/webapp/WEB-INF/classes/repository.properties Thu Nov 22 15:42:02 2012
@@ -29,6 +29,7 @@ InMemoryServer.TypeDefinitionsFile=types
# InMemoryServer.MemoryThreshold=10485760
# InMemoryServer.TempDir=/path/to/your/tmp
InMemoryServer.MaxSize=20971520
+InMemoryServer.EncryptTempFiles=true
# settings for init repository with data
# enable or disable