@Test public void testOverwritingWithTheSameIvIndex() { final byte[] data = MeshParserUtils.toByteArray("0102EE6C0EFF5298ECFF000000025E5AA7B268B5E044"); final SecureNetworkBeacon snb = new SecureNetworkBeacon(data); final IvIndex ivIndex = new IvIndex(2, true, Calendar.getInstance()); final Calendar rightNow = Calendar.getInstance(); rightNow.add(Calendar.HOUR, -1); final boolean result = snb.canOverwrite(ivIndex, rightNow, false, false, false); assertTrue("Cannot overrwrite iv index with a baecon with same index", result); }
protected boolean canOverwrite(final IvIndex ivIndex, final Calendar updatedAt, final boolean ivRecoveryActive, final boolean isTestMode, final boolean ivRecoveryOver42Allowed) { if ((this.ivIndex.getIvIndex() > ivIndex.getIvIndex() && (ivRecoveryOver42Allowed || this.ivIndex.getIvIndex() <= ivIndex.getIvIndex() + 42)) || (this.ivIndex.getIvIndex() == ivIndex.getIvIndex() && (ivIndex.isIvUpdateActive() || !this.ivIndex.isIvUpdateActive()))) { return isMinimumTimeRequirementCompleted(ivIndex, updatedAt, ivRecoveryActive, isTestMode); } else { return false; } }
SecureNetworkBeacon extends MeshBeacon { protected boolean canOverwrite(final IvIndex ivIndex, final Calendar updatedAt, final boolean ivRecoveryActive, final boolean isTestMode, final boolean ivRecoveryOver42Allowed) { if ((this.ivIndex.getIvIndex() > ivIndex.getIvIndex() && (ivRecoveryOver42Allowed || this.ivIndex.getIvIndex() <= ivIndex.getIvIndex() + 42)) || (this.ivIndex.getIvIndex() == ivIndex.getIvIndex() && (ivIndex.isIvUpdateActive() || !this.ivIndex.isIvUpdateActive()))) { return isMinimumTimeRequirementCompleted(ivIndex, updatedAt, ivRecoveryActive, isTestMode); } else { return false; } } }
SecureNetworkBeacon extends MeshBeacon { protected boolean canOverwrite(final IvIndex ivIndex, final Calendar updatedAt, final boolean ivRecoveryActive, final boolean isTestMode, final boolean ivRecoveryOver42Allowed) { if ((this.ivIndex.getIvIndex() > ivIndex.getIvIndex() && (ivRecoveryOver42Allowed || this.ivIndex.getIvIndex() <= ivIndex.getIvIndex() + 42)) || (this.ivIndex.getIvIndex() == ivIndex.getIvIndex() && (ivIndex.isIvUpdateActive() || !this.ivIndex.isIvUpdateActive()))) { return isMinimumTimeRequirementCompleted(ivIndex, updatedAt, ivRecoveryActive, isTestMode); } else { return false; } } SecureNetworkBeacon(@NonNull final byte[] beaconData); }
SecureNetworkBeacon extends MeshBeacon { protected boolean canOverwrite(final IvIndex ivIndex, final Calendar updatedAt, final boolean ivRecoveryActive, final boolean isTestMode, final boolean ivRecoveryOver42Allowed) { if ((this.ivIndex.getIvIndex() > ivIndex.getIvIndex() && (ivRecoveryOver42Allowed || this.ivIndex.getIvIndex() <= ivIndex.getIvIndex() + 42)) || (this.ivIndex.getIvIndex() == ivIndex.getIvIndex() && (ivIndex.isIvUpdateActive() || !this.ivIndex.isIvUpdateActive()))) { return isMinimumTimeRequirementCompleted(ivIndex, updatedAt, ivRecoveryActive, isTestMode); } else { return false; } } SecureNetworkBeacon(@NonNull final byte[] beaconData); @NonNull @Override String toString(); @Override int getBeaconType(); int getFlags(); boolean isKeyRefreshActive(); byte[] getNetworkId(); IvIndex getIvIndex(); byte[] getAuthenticationValue(); @Override int describeContents(); @Override void writeToParcel(final Parcel dest, final int flags); }
SecureNetworkBeacon extends MeshBeacon { protected boolean canOverwrite(final IvIndex ivIndex, final Calendar updatedAt, final boolean ivRecoveryActive, final boolean isTestMode, final boolean ivRecoveryOver42Allowed) { if ((this.ivIndex.getIvIndex() > ivIndex.getIvIndex() && (ivRecoveryOver42Allowed || this.ivIndex.getIvIndex() <= ivIndex.getIvIndex() + 42)) || (this.ivIndex.getIvIndex() == ivIndex.getIvIndex() && (ivIndex.isIvUpdateActive() || !this.ivIndex.isIvUpdateActive()))) { return isMinimumTimeRequirementCompleted(ivIndex, updatedAt, ivRecoveryActive, isTestMode); } else { return false; } } SecureNetworkBeacon(@NonNull final byte[] beaconData); @NonNull @Override String toString(); @Override int getBeaconType(); int getFlags(); boolean isKeyRefreshActive(); byte[] getNetworkId(); IvIndex getIvIndex(); byte[] getAuthenticationValue(); @Override int describeContents(); @Override void writeToParcel(final Parcel dest, final int flags); static final int BEACON_DATA_LENGTH; static final Parcelable.Creator<SecureNetworkBeacon> CREATOR; }