This repository was archived by the owner on Oct 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathCastVote.java
More file actions
54 lines (43 loc) · 1.42 KB
/
CastVote.java
File metadata and controls
54 lines (43 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package org.rulez.demokracia.pdengine;
import java.util.ArrayList;
import java.util.List;
import org.rulez.demokracia.pdengine.dataobjects.CastVoteEntity;
public class CastVote extends CastVoteEntity implements CastVoteInterface {
private static final long serialVersionUID = 1L;
public CastVote(final String proxyId, final List<RankedChoice> preferences) {
super();
this.proxyId = proxyId;
this.preferences = new ArrayList<>(preferences);
secretId = RandomUtils.createRandomKey();
}
public CastVote(
final String proxyId, final List<RankedChoice> preferences,
final List<String> assurances
) {
this(proxyId, preferences);
this.assurances = assurances;
}
@Override
public List<RankedChoice> getPreferences() {
return preferences;
}
@Override
public List<String> getAssurances() {
return assurances;
}
public String contentToBeSigned() {
final StringBuilder str = new StringBuilder();
final String delimiter = "|";
str.append(proxyId).append(delimiter)
.append(secretId).append(delimiter);
for (final RankedChoice rc : preferences)
str.append(rc.id).append(delimiter)
.append(rc.choiceId).append(delimiter)
.append(rc.rank).append(delimiter);
return str.toString();
}
public void updateSignature() {
signature = MessageSigner.getInstance()
.signatureOfMessage(contentToBeSigned().getBytes());
}
}