Page MenuHomec4science

RequestDecryption.java
No OneTemporary

File Metadata

Created
Fri, May 2, 18:23

RequestDecryption.java

package framework.request;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.json.JSONException;
import org.json.JSONObject;
import crypto.elgamal.fragment.FragmentEncoded;
import framework.Type;
import framework.test.TestResultEncoded;
import framework.test.TestResultEncrypted;
public class RequestDecryption extends Request {
private static final Logger LOGGER = Logger.getLogger(RequestDecryption.class.getName());
private long timestamp;
private LinkedList<TestResultEncoded> encodedResults;
private ArrayList<LinkedList<FragmentEncoded>> encodedHLAs;
public RequestDecryption(int id_p, LinkedList<TestResultEncoded> encodedResults,
ArrayList<LinkedList<FragmentEncoded>> encodedHLAs) {
super(Type.DECRYPT, id_p);
this.encodedResults = encodedResults;
this.encodedHLAs = encodedHLAs;
}
public RequestDecryption(int id_p, ArrayList<LinkedList<FragmentEncoded>> encodedHLAs, LinkedList<TestResultEncrypted> encryptedResults) {
super(Type.DECRYPT, id_p);
this.encodedResults = new LinkedList<>();
if (encryptedResults != null) {
addAllEncryptedResults(encryptedResults);
}
this.encodedHLAs = encodedHLAs;
}
private void addAllEncryptedResults(LinkedList<TestResultEncrypted> encryptedResults) {
for (TestResultEncrypted testResultEncrypted : encryptedResults) {
if (testResultEncrypted != null) {
encodedResults.add(new TestResultEncoded(testResultEncrypted));
} else {
encodedResults.add(null);
}
}
}
public LinkedList<TestResultEncoded> getEncodedResults() {
return encodedResults;
}
public ArrayList<LinkedList<FragmentEncoded>> getEncodedHLAs() {
return encodedHLAs;
}
public JSONObject getJSONRqt() throws JSONException {
JSONObject jsonRqtDecrypt = new JSONObject();
jsonRqtDecrypt.put(Request.JSON_KEY_TYPE, Type.DECRYPT);
jsonRqtDecrypt.put(Request.JSON_KEY_RQT, this);
return jsonRqtDecrypt;
}
public static RequestDecryption getRequestDecrypt(JSONObject jsonRqtDecrypt) {
try {
RequestDecryption rqtDecrypt = (RequestDecryption) jsonRqtDecrypt.get(Request.JSON_KEY_RQT);
return rqtDecrypt;
} catch (JSONException e) {
LOGGER.log(Level.SEVERE, null, e);
return null;
}
}
public long getTimestamp() {
return timestamp;
}
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
}

Event Timeline