void initBase(byte[] buffer, int sequenceId) { long timestamp = System.currentTimeMillis(); synchronized (this) { // Don't let timestamp go backwards, at least "on our watch" (while this JVM is running). We are still vulnerable if we are // shut down, clock goes backwards, and we restart... for this we randomize the sequenceNumber on init to decrease chance of // collision: timestamp = Math.max(lastTimestamp, timestamp); if (sequenceId == 0) { // Always force the clock to increment whenever sequence number is 0, in case we have a long time-slip backwards: timestamp++; } lastTimestamp = timestamp; } // Only use lower 6 bytes of the timestamp (this will suffice beyond the year 10000): putLong(buffer, timestamp, 0, 6); // MAC address adds 6 bytes: System.arraycopy(secureMungedAddress, 0, buffer, 6, secureMungedAddress.length); }
void initBase(byte[] buffer, int sequenceId) { long timestamp = System.currentTimeMillis(); synchronized (this) { // Don't let timestamp go backwards, at least "on our watch" (while this JVM is running). We are still vulnerable if we are // shut down, clock goes backwards, and we restart... for this we randomize the sequenceNumber on init to decrease chance of // collision: timestamp = Math.max(lastTimestamp, timestamp); if (sequenceId == 0) { // Always force the clock to increment whenever sequence number is 0, in case we have a long time-slip backwards: timestamp++; } lastTimestamp = timestamp; } // Only use lower 6 bytes of the timestamp (this will suffice beyond the year 10000): putLong(buffer, timestamp, 0, 6); // MAC address adds 6 bytes: System.arraycopy(secureMungedAddress, 0, buffer, 6, secureMungedAddress.length); }
protected byte[] generate(byte[] buffer, int increment) { // Sequence number adds 3 bytes putLong(buffer, increment, 12, 3); return buffer; }
protected byte[] generate(byte[] buffer, int increment) { // Sequence number adds 3 bytes putLong(buffer, increment, 12, 3); return buffer; }