Author: mpodolin
Date: 2010-02-24 10:45:14 -0500 (Wed, 24 Feb 2010)
New Revision: 1849
Modified:
portal/trunk/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/ExoDefaultSecurityTokenGenerator.java
Log:
GTNPORTAL-708: fixed an encryption key lookup method to search in the common config.
directory
Modified:
portal/trunk/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/ExoDefaultSecurityTokenGenerator.java
===================================================================
---
portal/trunk/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/ExoDefaultSecurityTokenGenerator.java 2010-02-24
13:48:33 UTC (rev 1848)
+++
portal/trunk/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/ExoDefaultSecurityTokenGenerator.java 2010-02-24
15:45:14 UTC (rev 1849)
@@ -19,16 +19,17 @@
package org.exoplatform.portal.gadget.core;
+import java.io.File;
+import java.io.IOException;
+
import org.apache.shindig.auth.BlobCrypterSecurityToken;
import org.apache.shindig.common.crypto.BasicBlobCrypter;
import org.apache.shindig.common.crypto.BlobCrypter;
import org.apache.shindig.common.crypto.BlobCrypterException;
import org.apache.shindig.common.util.TimeSource;
+import org.exoplatform.container.monitor.jvm.J2EEServerInfo;
import org.exoplatform.web.application.RequestContext;
-import java.io.File;
-import java.io.IOException;
-
public class ExoDefaultSecurityTokenGenerator implements SecurityTokenGenerator
{
private String containerKey;
@@ -39,7 +40,7 @@
{
// TODO should be moved to config
// generateKeys("RSA", 1024);
- this.containerKey = "key.txt";
+ this.containerKey = getKeyFilePath();
this.timeSource = new TimeSource();
}
@@ -129,4 +130,25 @@
return c;
}
+ /**
+ * Method returns a path to the file containing the encryption key
+ */
+ private String getKeyFilePath(){
+ J2EEServerInfo info = new J2EEServerInfo();
+ String confPath = info.getExoConfigurationDirectory();
+ File keyFile = null;
+
+ if (confPath != null) {
+ File confDir = new File(confPath);
+ if (confDir != null && confDir.exists() &&
confDir.isDirectory()) {
+ keyFile = new File(confDir, "gadgets/key.txt");
+ }
+ }
+
+ if (keyFile == null) {
+ keyFile = new File("key.txt");
+ }
+
+ return keyFile.getAbsolutePath();
+ }
}
Show replies by date