示例#1
0
 public synchronized boolean equals(java.lang.Object obj) {
   if (!(obj instanceof Data)) return false;
   Data other = (Data) obj;
   if (obj == null) return false;
   if (this == obj) return true;
   if (__equalsCalc != null) {
     return (__equalsCalc == obj);
   }
   __equalsCalc = obj;
   boolean _equals;
   _equals =
       true
           && ((this.type == null && other.getType() == null)
               || (this.type != null && this.type.equals(other.getType())))
           && ((this.content == null && other.getContent() == null)
               || (this.content != null && this.content.equals(other.getContent())));
   __equalsCalc = null;
   return _equals;
 }
示例#2
0
文件: OCPAgent.java 项目: ccbon/ocp
 private Key[] getKeys(OCPUser user, Pointer pointer) throws Exception {
   Key pointerKey = new Key(pointer.getBytes());
   Data data = (Data) get(pointerKey);
   if (data == null) {
     throw new Exception("Cannot get keys for pointer " + pointer);
   }
   byte[] ciphertext = data.getContent();
   byte[] cleartext = user.decrypt(ciphertext);
   Key[] keys = (Key[]) ds().serializer.deserialize(cleartext);
   return keys;
 }
示例#3
0
文件: OCPAgent.java 项目: ccbon/ocp
 public UserPublicInfo getUserPublicInfo(byte[] username) throws Exception {
   String sUsername = new String(username);
   UserPublicInfo upi = (UserPublicInfo) cache.get(UserPublicInfo.class, sUsername);
   if (upi != null) {
     return upi;
   }
   Key key = UserPublicInfo.getKey(this, sUsername);
   Data data = (Data) get(key);
   if (data == null) {
     throw new Exception("Cannot get the user public info for " + sUsername);
   }
   upi = (UserPublicInfo) ds().serializer.deserialize(data.getContent());
   cache.put(UserPublicInfo.class, sUsername, upi);
   return upi;
 }
示例#4
0
文件: OCPAgent.java 项目: ccbon/ocp
  public byte[] getBytes(OCPUser user, Pointer pointer) throws Exception {
    // 1) retrieve the key list from pointer
    Key[] keys = getKeys(user, pointer);
    // 2) from each key retrieve the object
    if (keys.length != user.getBackupNbr()) {
      throw new Exception("nbr of keys different from user backup nbr.");
    }
    byte[] result = null;
    // TODO : check if all bkp are identical and repair if necessary
    for (int i = 0; i < keys.length; i++) {
      Data data = (Data) get(keys[i]);
      if (data != null) {
        byte[] ciphertext = data.getContent();
        byte[] cleartext = user.decrypt(ciphertext);
        result = ByteUtil.sub(cleartext, 1);

        break;
      }
    }
    return result;
  }