1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package io.github.tonywasher.joceanus.prometheus.sheets;
18
19 import io.github.tonywasher.joceanus.oceanus.base.OceanusException;
20 import io.github.tonywasher.joceanus.prometheus.data.PrometheusControlKeySet;
21 import io.github.tonywasher.joceanus.prometheus.data.PrometheusDataKeySet;
22 import io.github.tonywasher.joceanus.prometheus.data.PrometheusDataResource;
23 import io.github.tonywasher.joceanus.prometheus.data.PrometheusDataSet;
24 import io.github.tonywasher.joceanus.prometheus.data.PrometheusDataSet.PrometheusCryptographyDataType;
25 import io.github.tonywasher.joceanus.prometheus.data.PrometheusDataValues;
26
27
28
29
30
31
32 public class PrometheusSheetControlKeySet
33 extends PrometheusSheetDataItem<PrometheusControlKeySet> {
34
35
36
37 private static final String SHEET_NAME = PrometheusControlKeySet.class.getSimpleName();
38
39
40
41
42 private static final int COL_CONTROL = COL_ID + 1;
43
44
45
46
47 private static final int COL_KEYSETDEF = COL_CONTROL + 1;
48
49
50
51
52
53
54 protected PrometheusSheetControlKeySet(final PrometheusSheetReader pReader) {
55
56 super(pReader, SHEET_NAME);
57
58
59 final PrometheusDataSet myData = pReader.getData();
60 setDataList(myData.getControlKeySets());
61 }
62
63
64
65
66
67
68 protected PrometheusSheetControlKeySet(final PrometheusSheetWriter pWriter) {
69
70 super(pWriter, SHEET_NAME);
71
72
73 final PrometheusDataSet myData = pWriter.getData();
74 setDataList(myData.getControlKeySets());
75 }
76
77 @Override
78 protected PrometheusDataValues loadSecureValues() throws OceanusException {
79
80 final PrometheusDataValues myValues = getRowValues(PrometheusDataKeySet.OBJECT_NAME);
81 myValues.addValue(PrometheusCryptographyDataType.CONTROLKEY, loadInteger(COL_CONTROL));
82 myValues.addValue(PrometheusDataResource.KEYSET_KEYSETDEF, loadBytes(COL_KEYSETDEF));
83
84
85 return myValues;
86 }
87
88 @Override
89 protected void insertSecureItem(final PrometheusControlKeySet pItem) throws OceanusException {
90
91 super.insertSecureItem(pItem);
92 writeInteger(COL_CONTROL, pItem.getControlKeyId());
93 writeBytes(COL_KEYSETDEF, pItem.getSecuredKeySetDef());
94 }
95
96 @Override
97 protected int getLastColumn() {
98
99 return COL_KEYSETDEF;
100 }
101 }