Class DiagnosisKey
- java.lang.Object
-
- app.coronawarn.server.common.persistence.domain.DiagnosisKey
-
public class DiagnosisKey extends Object
A key generated for advertising over a window of time.
-
-
Field Summary
Fields Modifier and Type Field Description static intEXPECTED_ROLLING_PERIODAccording to "Setting Up an Exposure Notification Server" by Apple, exposure notification servers are expected to reject any diagnosis keys that do not have a rolling period of a certain fixed value.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.Builderbuilder()Returns a DiagnosisKeyBuilder instance.booleanequals(Object o)byte[]getKeyData()Returns the diagnosis key.intgetRollingPeriod()Returns a number describing how long a key is valid.intgetRollingStartIntervalNumber()Returns a number describing when a key starts.longgetSubmissionTimestamp()Returns the timestamp associated with the submission of thisDiagnosisKeyas hours since epoch.intgetTransmissionRiskLevel()Returns the risk of transmission associated with the person this key came from.inthashCode()booleanisYoungerThanRetentionThreshold(int daysToRetain)Checks if this diagnosis key falls into the period between now, and the retention threshold.Set<javax.validation.ConstraintViolation<DiagnosisKey>>validate()Gets any constraint violations that this key might incorporate.
-
-
-
Field Detail
-
EXPECTED_ROLLING_PERIOD
public static final int EXPECTED_ROLLING_PERIOD
According to "Setting Up an Exposure Notification Server" by Apple, exposure notification servers are expected to reject any diagnosis keys that do not have a rolling period of a certain fixed value. See https://developer.apple.com/documentation/exposurenotification/setting_up_an_exposure_notification_server- See Also:
- Constant Field Values
-
-
Method Detail
-
builder
public static app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.Builder builder()
Returns a DiagnosisKeyBuilder instance. ADiagnosisKeycan then be build by either providing the required member values or by passing the respective protocol buffer object.- Returns:
- DiagnosisKeyBuilder instance.
-
getKeyData
public byte[] getKeyData()
Returns the diagnosis key.
-
getRollingStartIntervalNumber
public int getRollingStartIntervalNumber()
Returns a number describing when a key starts. It is equal to startTimeOfKeySinceEpochInSecs / (60 * 10).
-
getRollingPeriod
public int getRollingPeriod()
Returns a number describing how long a key is valid. It is expressed in increments of 10 minutes (e.g. 144 for 24 hours).
-
getTransmissionRiskLevel
public int getTransmissionRiskLevel()
Returns the risk of transmission associated with the person this key came from.
-
getSubmissionTimestamp
public long getSubmissionTimestamp()
Returns the timestamp associated with the submission of thisDiagnosisKeyas hours since epoch.
-
isYoungerThanRetentionThreshold
public boolean isYoungerThanRetentionThreshold(int daysToRetain)
Checks if this diagnosis key falls into the period between now, and the retention threshold.- Parameters:
daysToRetain- the number of days before a key is outdated- Returns:
- true, if the rolling start interval number is within the time between now, and the given days to retain
- Throws:
IllegalArgumentException- ifdaysToRetainis negative.
-
validate
public Set<javax.validation.ConstraintViolation<DiagnosisKey>> validate()
Gets any constraint violations that this key might incorporate.- Risk level must be between 0 and 8
- Rolling start interval number must be greater than 0
- Rolling start number cannot be in the future
- Rolling period must be positive number
- Key data must be byte array of length 16
- Returns:
- A set of constraint violations of this key.
-
-