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 int
MAX_ROLLING_PERIOD
static int
MIN_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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.Builder
builder()
Returns a DiagnosisKeyBuilder instance.boolean
equals(Object o)
byte[]
getKeyData()
Returns the diagnosis key.int
getRollingPeriod()
Returns a number describing how long a key is valid.int
getRollingStartIntervalNumber()
Returns a number describing when a key starts.long
getSubmissionTimestamp()
Returns the timestamp associated with the submission of thisDiagnosisKey
as hours since epoch.int
getTransmissionRiskLevel()
Returns the risk of transmission associated with the person this key came from.int
hashCode()
boolean
isYoungerThanRetentionThreshold(int daysToRetain)
Checks if this diagnosis key falls into the period between now, and the retention threshold.String
toString()
Set<javax.validation.ConstraintViolation<DiagnosisKey>>
validate()
Gets any constraint violations that this key might incorporate.
-
-
-
Field Detail
-
MIN_ROLLING_PERIOD
public static final int MIN_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
-
MAX_ROLLING_PERIOD
public static final int MAX_ROLLING_PERIOD
- See Also:
- Constant Field Values
-
-
Method Detail
-
builder
public static app.coronawarn.server.common.persistence.domain.DiagnosisKeyBuilders.Builder builder()
Returns a DiagnosisKeyBuilder instance. ADiagnosisKey
can 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 thisDiagnosisKey
as 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
- ifdaysToRetain
is 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.
-
-