Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F104714860
ReplyMaterial.java
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Mar 11, 18:38
Size
2 KB
Mime Type
text/x-java
Expires
Thu, Mar 13, 18:38 (2 d)
Engine
blob
Format
Raw Data
Handle
24823574
Attached To
R3229 Genome Privacy - SHCS App
ReplyMaterial.java
View Options
package
framework.reply
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
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.ECElGamal
;
import
crypto.elgamal.fragment.FragmentEncoded
;
import
crypto.elgamal.fragment.FragmentEncrypted
;
import
framework.Marker
;
import
framework.MarkerEncrypted
;
import
framework.Type
;
import
framework.request.Request
;
public
class
ReplyMaterial
{
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
ReplyMaterial
.
class
.
getName
());
private
HashMap
<
MarkerEncrypted
,
FragmentEncoded
>
encodedMarkers
;
private
HashMap
<
MarkerEncrypted
,
FragmentEncoded
>
encodedCFs
;
private
ArrayList
<
LinkedList
<
FragmentEncoded
>>
encodedHLAs
;
public
ReplyMaterial
(
HashMap
<
MarkerEncrypted
,
FragmentEncoded
>
encodedMarkers
,
HashMap
<
MarkerEncrypted
,
FragmentEncoded
>
encodedCFs
,
ArrayList
<
LinkedList
<
FragmentEncoded
>>
encodedHLAs
)
{
this
.
encodedMarkers
=
encodedMarkers
;
this
.
encodedCFs
=
encodedCFs
;
this
.
encodedHLAs
=
encodedHLAs
;
}
public
HashMap
<
MarkerEncrypted
,
FragmentEncoded
>
getEncodedMarkers
()
{
return
encodedMarkers
;
}
public
HashMap
<
MarkerEncrypted
,
FragmentEncoded
>
getEncodedCFs
()
{
return
encodedCFs
;
}
public
ArrayList
<
LinkedList
<
FragmentEncoded
>>
getEncodedHLAs
()
{
return
encodedHLAs
;
}
public
static
ReplyMaterial
getReplyMaterial
(
JSONObject
jsonReplyMaterial
)
{
try
{
ReplyMaterial
replyMaterial
=
(
ReplyMaterial
)
jsonReplyMaterial
.
get
(
Request
.
JSON_KEY_REP
);
return
replyMaterial
;
}
catch
(
JSONException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
"Could not find Reply component"
,
e
);
return
null
;
}
}
public
HashMap
<
Marker
,
FragmentEncrypted
>
getEncryptedMarkers
(
ECElGamal
cryptoEng
)
{
HashMap
<
Marker
,
FragmentEncrypted
>
result
=
new
HashMap
<>();
for
(
MarkerEncrypted
markerEnc
:
encodedMarkers
.
keySet
())
{
FragmentEncoded
fragEncoded
=
encodedMarkers
.
get
(
markerEnc
);
FragmentEncrypted
fragEncrypted
=
fragEncoded
.
decodeFragment
(
cryptoEng
);
Marker
marker
=
new
Marker
(
markerEnc
.
getMarker
());
result
.
put
(
marker
,
fragEncrypted
);
}
return
result
;
}
public
HashMap
<
Integer
,
FragmentEncrypted
>
getEncryptedCFs
(
ECElGamal
cryptoEng
)
{
HashMap
<
Integer
,
FragmentEncrypted
>
result
=
new
HashMap
<>();
for
(
MarkerEncrypted
markerEnc
:
encodedCFs
.
keySet
())
{
FragmentEncoded
fragEncoded
=
encodedCFs
.
get
(
markerEnc
);
FragmentEncrypted
fragEncrypted
=
fragEncoded
.
decodeFragment
(
cryptoEng
);
Integer
marker
=
Integer
.
valueOf
(
markerEnc
.
toString
());
result
.
put
(
marker
,
fragEncrypted
);
}
return
result
;
}
public
JSONObject
getJSONReply
()
throws
JSONException
{
JSONObject
jsonReplyMaterial
=
new
JSONObject
();
jsonReplyMaterial
.
put
(
Request
.
JSON_KEY_TYPE
,
Type
.
MATERIAL
);
jsonReplyMaterial
.
put
(
Request
.
JSON_KEY_REP
,
this
);
return
jsonReplyMaterial
;
}
}
Event Timeline
Log In to Comment