Author: lindner
Date: Fri Jun 5 21:01:56 2009
New Revision: 782134
URL: http://svn.apache.org/viewvc?rev=782134&view=rev
Log:
SHINDIG-1081 | Allow for BlobCrypter classes to be extended.
Modified:
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/BlobCrypterSecurityToken.java
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/BlobCrypterSecurityTokenDecoder.java
Modified:
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/BlobCrypterSecurityToken.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/BlobCrypterSecurityToken.java?rev=782134&r1=782133&r2=782134&view=diff
==============================================================================
---
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/BlobCrypterSecurityToken.java
(original)
+++
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/BlobCrypterSecurityToken.java
Fri Jun 5 21:01:56 2009
@@ -34,24 +34,24 @@
*/
public class BlobCrypterSecurityToken implements SecurityToken {
- private static final int MAX_TOKEN_LIFETIME_SECS = 3600;
+ protected static final int MAX_TOKEN_LIFETIME_SECS = 3600;
- private static final String OWNER_KEY = "o";
- private static final String VIEWER_KEY = "v";
- private static final String GADGET_KEY = "g";
- private static final String GADGET_INSTANCE_KEY = "i";
- private static final String TRUSTED_JSON_KEY = "j";
-
- private final BlobCrypter crypter;
- private final String container;
- private final String domain;
-
- private String ownerId;
- private String viewerId;
- private String appUrl;
- private long moduleId;
- private String trustedJson;
- private String activeUrl;
+ protected static final String OWNER_KEY = "o";
+ protected static final String VIEWER_KEY = "v";
+ protected static final String GADGET_KEY = "g";
+ protected static final String GADGET_INSTANCE_KEY = "i";
+ protected static final String TRUSTED_JSON_KEY = "j";
+
+ protected final BlobCrypter crypter;
+ protected final String container;
+ protected final String domain;
+
+ protected String ownerId;
+ protected String viewerId;
+ protected String appUrl;
+ protected long moduleId;
+ protected String trustedJson;
+ protected String activeUrl;
/**
* Create a new security token.
@@ -82,16 +82,20 @@
String token, String activeUrl) throws BlobCrypterException {
Map<String, String> values = crypter.unwrap(token,
MAX_TOKEN_LIFETIME_SECS);
BlobCrypterSecurityToken t = new BlobCrypterSecurityToken(crypter,
container, domain);
- t.setOwnerId(values.get(OWNER_KEY));
- t.setViewerId(values.get(VIEWER_KEY));
- t.setAppUrl(values.get(GADGET_KEY));
+ setTokenValues(t, values);
+ t.setActiveUrl(activeUrl);
+ return t;
+ }
+
+ protected static void setTokenValues(BlobCrypterSecurityToken token,
Map<String, String> values) {
+ token.setOwnerId(values.get(OWNER_KEY));
+ token.setViewerId(values.get(VIEWER_KEY));
+ token.setAppUrl(values.get(GADGET_KEY));
String moduleId = values.get(GADGET_INSTANCE_KEY);
if (moduleId != null) {
- t.setModuleId(Long.parseLong(moduleId));
+ token.setModuleId(Long.parseLong(moduleId));
}
- t.setTrustedJson(values.get(TRUSTED_JSON_KEY));
- t.setActiveUrl(activeUrl);
- return t;
+ token.setTrustedJson(values.get(TRUSTED_JSON_KEY));
}
/**
@@ -99,6 +103,11 @@
* encoded before being used as a form parameter.
*/
public String encrypt() throws BlobCrypterException {
+ Map<String, String> values = buildValuesMap();
+ return container + ':' + crypter.wrap(values);
+ }
+
+ protected Map<String, String> buildValuesMap() {
Map<String, String> values = Maps.newHashMap();
if (ownerId != null) {
values.put(OWNER_KEY, ownerId);
@@ -115,8 +124,8 @@
if (trustedJson != null) {
values.put(TRUSTED_JSON_KEY, trustedJson);
}
- return container + ':' + crypter.wrap(values);
- }
+ return values;
+ }
// Legacy value for signed fetch, opensocial 0.8 prefers opensocial_app_url
public String getAppId() {
Modified:
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/BlobCrypterSecurityTokenDecoder.java
URL:
http://svn.apache.org/viewvc/incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/BlobCrypterSecurityTokenDecoder.java?rev=782134&r1=782133&r2=782134&view=diff
==============================================================================
---
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/BlobCrypterSecurityTokenDecoder.java
(original)
+++
incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/auth/BlobCrypterSecurityTokenDecoder.java
Fri Jun 5 21:01:56 2009
@@ -54,12 +54,12 @@
/**
* Keys are container ids, values are crypters
*/
- private final Map<String, BlobCrypter> crypters = Maps.newHashMap();
+ protected final Map<String, BlobCrypter> crypters = Maps.newHashMap();
/**
* Keys are container ids, values are domains used for signed fetch.
*/
- private final Map<String, String> domains = Maps.newHashMap();
+ protected final Map<String, String> domains = Maps.newHashMap();
@Inject
public BlobCrypterSecurityTokenDecoder(ContainerConfig config) {