diff options
author | Lars Vogel | 2019-09-05 14:07:35 +0000 |
---|---|---|
committer | Lars Vogel | 2019-09-16 19:26:16 +0000 |
commit | 6d6024405150abe1eab4fbf3eb8144aac825c81c (patch) | |
tree | 47fd0b7f89235ab710c90c785dc755d719ca62a3 /bundles/org.eclipse.equinox.p2.artifact.repository/src | |
parent | a53e000c33e61d264e6b2802d7a0389ee806ff1d (diff) | |
download | rt.equinox.p2-6d6024405150abe1eab4fbf3eb8144aac825c81c.tar.gz rt.equinox.p2-6d6024405150abe1eab4fbf3eb8144aac825c81c.tar.xz rt.equinox.p2-6d6024405150abe1eab4fbf3eb8144aac825c81c.zip |
Bug 512678 - avoid locking the UI via IP access to seed SecureRandom
with Random
Also removes unsed getIPAddress method
Change-Id: I68e123ae8da73bb32be457507fe8e7b919cdb3ae
Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.artifact.repository/src')
-rw-r--r-- | bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/UniversalUniqueIdentifier.java | 48 |
1 files changed, 3 insertions, 45 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/UniversalUniqueIdentifier.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/UniversalUniqueIdentifier.java index ed4518abb..90fa151e9 100644 --- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/UniversalUniqueIdentifier.java +++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/UniversalUniqueIdentifier.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2017 IBM Corporation and others. + * Copyright (c) 2000, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -13,10 +13,7 @@ *******************************************************************************/ package org.eclipse.equinox.internal.p2.artifact.repository.simple; -import java.io.*; import java.math.BigInteger; -import java.net.InetAddress; -import java.net.UnknownHostException; import java.security.SecureRandom; import java.util.GregorianCalendar; import java.util.Random; @@ -127,7 +124,7 @@ public class UniversalUniqueIdentifier implements java.io.Serializable { try { return super.clone(); } catch (CloneNotSupportedException e) { - Assert.isTrue(false, "Clone not supported"); + Assert.isTrue(false, "Clone not supported"); //$NON-NLS-1$ return null; } } @@ -148,28 +145,7 @@ public class UniversalUniqueIdentifier implements java.io.Serializable { private static byte[] computeNodeAddress() { byte[] address = new byte[NODE_ADDRESS_BYTE_SIZE]; - - // Seed the secure randomizer with some oft-varying inputs - int thread = Thread.currentThread().hashCode(); - long time = System.currentTimeMillis(); - int objectId = System.identityHashCode(new String()); - ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); - DataOutputStream out = new DataOutputStream(byteOut); - byte[] ipAddress = getIPAddress(); - - try { - if (ipAddress != null) - out.write(ipAddress); - out.write(thread); - out.writeLong(time); - out.write(objectId); - out.close(); - } catch (IOException exc) { - //ignore the failure, we're just trying to come up with a random seed - } - byte[] rand = byteOut.toByteArray(); - - SecureRandom randomizer = new SecureRandom(rand); + SecureRandom randomizer = new SecureRandom(); randomizer.nextBytes(address); // set the MSB of the first octet to 1 to distinguish from IEEE node addresses @@ -197,24 +173,6 @@ public class UniversalUniqueIdentifier implements java.io.Serializable { return true; } - /** - Answers the IP address of the local machine using the - Java API class <code>InetAddress</code>. - - @return byte[] the network address in network order - @see java.net.InetAddress#getLocalHost() - @see java.net.InetAddress#getAddress() - */ - protected static byte[] getIPAddress() { - try { - return InetAddress.getLocalHost().getAddress(); - } catch (UnknownHostException e) { - //valid for this to be thrown be a machine with no IP connection - //It is VERY important NOT to throw this exception - return null; - } - } - private static byte[] getNodeAddress() { return nodeAddress; } |