Class DiagnosisKey
- java.lang.Object
-
- app.coronawarn.server.common.persistence.domain.DiagnosisKey
-
- Direct Known Subclasses:
FederationUploadKey
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
KEY_DATA_LENGTH
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.static int
MAX_DAYS_SINCE_ONSET_OF_SYMPTOMS
static int
MAX_ROLLING_PERIOD
static int
MAX_TRANSMISSION_RISK_LEVEL
static int
MIN_DAYS_SINCE_ONSET_OF_SYMPTOMS
static int
MIN_ROLLING_PERIOD
static int
MIN_TRANSMISSION_RISK_LEVEL
static long
ROLLING_PERIOD_MINUTES_INTERVAL
-
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)
int
getDaysSinceOnsetOfSymptoms()
byte[]
getKeyData()
Returns the diagnosis key.String
getOriginCountry()
ReportType
getReportType()
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.Set<String>
getVisitedCountries()
int
hashCode()
boolean
isConsentToFederation()
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
-
ROLLING_PERIOD_MINUTES_INTERVAL
public static final long ROLLING_PERIOD_MINUTES_INTERVAL
- See Also:
- Constant Field Values
-
KEY_DATA_LENGTH
public static final int KEY_DATA_LENGTH
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
-
MIN_ROLLING_PERIOD
public static final int MIN_ROLLING_PERIOD
- See Also:
- Constant Field Values
-
MAX_ROLLING_PERIOD
public static final int MAX_ROLLING_PERIOD
- See Also:
- Constant Field Values
-
MIN_DAYS_SINCE_ONSET_OF_SYMPTOMS
public static final int MIN_DAYS_SINCE_ONSET_OF_SYMPTOMS
- See Also:
- Constant Field Values
-
MAX_DAYS_SINCE_ONSET_OF_SYMPTOMS
public static final int MAX_DAYS_SINCE_ONSET_OF_SYMPTOMS
- See Also:
- Constant Field Values
-
MIN_TRANSMISSION_RISK_LEVEL
public static final int MIN_TRANSMISSION_RISK_LEVEL
- See Also:
- Constant Field Values
-
MAX_TRANSMISSION_RISK_LEVEL
public static final int MAX_TRANSMISSION_RISK_LEVEL
- 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.
-
isConsentToFederation
public boolean isConsentToFederation()
-
getOriginCountry
public String getOriginCountry()
-
getReportType
public ReportType getReportType()
-
getDaysSinceOnsetOfSymptoms
public int getDaysSinceOnsetOfSymptoms()
-
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.
-
-