--- a/server/src/main/java/org/iri_research/renkan/models/Project.java Thu Mar 14 13:48:35 2013 +0100
+++ b/server/src/main/java/org/iri_research/renkan/models/Project.java Fri Mar 15 10:38:05 2013 +0100
@@ -10,6 +10,7 @@
import org.apache.commons.codec.binary.Hex;
import org.iri_research.renkan.Constants;
+import org.iri_research.renkan.Constants.EditMode;
import org.iri_research.renkan.RenkanException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -97,16 +98,22 @@
return spaceId;
}
- private String getRawKey(String prefix) {
+ private String getRawKey(String prefix, Constants.EditMode editMode) {
StringBuffer key = new StringBuffer(prefix!=null?prefix+"|":"");
key.append(Constants.KEYHEX);
key.append(this.getId());
key.append('|');
key.append(this.getCreated().getTime());
+ key.append('|');
+ key.append(editMode.toString());
return key.toString();
}
- public String getKey() throws RenkanException {
+ public String getKey(int editMode) throws RenkanException {
+ return this.getKey(EditMode.fromInt(editMode));
+ }
+
+ public String getKey(Constants.EditMode editMode) throws RenkanException {
// get salt
SecureRandom rand;
@@ -119,13 +126,13 @@
rand.nextBytes(salt);
String hex_salt = Hex.encodeHexString(salt);
- return hex_salt+"-"+this.getKey(hex_salt);
+ return hex_salt+"-"+this.getKey(hex_salt, editMode);
}
- private String getKey(String hex_salt) throws RenkanException {
+ private String getKey(String hex_salt, Constants.EditMode editMode) throws RenkanException {
- String rawKey = this.getRawKey(hex_salt);
+ String rawKey = this.getRawKey(hex_salt, editMode);
MessageDigest md;
try {
@@ -143,7 +150,7 @@
return key;
}
- public boolean checkKey(String key) throws RenkanException {
+ public boolean checkKey(String key, Constants.EditMode editMode) throws RenkanException {
if(key == null || key.isEmpty()) {
@@ -158,7 +165,7 @@
String salt = key_parts[0];
String signature = key_parts[1];
- String new_key = this.getKey(salt);
+ String new_key = this.getKey(salt, editMode);
return new_key.equals(signature);
}