Author: mpodolin
Date: 2010-02-22 08:29:58 -0500 (Mon, 22 Feb 2010)
New Revision: 1801
Modified:
portal/branches/EPP_5_0_0_ER03_Branch/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/ExoDefaultSecurityTokenGenerator.java
Log:
GTNPORTAL-708: fixed an encryption key lookup method
Modified:
portal/branches/EPP_5_0_0_ER03_Branch/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/ExoDefaultSecurityTokenGenerator.java
===================================================================
---
portal/branches/EPP_5_0_0_ER03_Branch/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/ExoDefaultSecurityTokenGenerator.java 2010-02-22
13:06:28 UTC (rev 1800)
+++
portal/branches/EPP_5_0_0_ER03_Branch/gadgets/core/src/main/java/org/exoplatform/portal/gadget/core/ExoDefaultSecurityTokenGenerator.java 2010-02-22
13:29:58 UTC (rev 1801)
@@ -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,8 @@
{
// TODO should be moved to config
// generateKeys("RSA", 1024);
- this.containerKey = "key.txt";
+
+ this.containerKey = getKeyFilePath();
this.timeSource = new TimeSource();
}
@@ -128,5 +130,26 @@
c.timeSource = timeSource;
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.exists() && confDir.isDirectory()) {
+ keyFile = new File(confDir, "gadgets/key.txt");
+ }
+ }
+ if (keyFile == null) {
+ keyFile = new File("key.txt");
+ }
+
+ return keyFile.getAbsolutePath();
+ }
}