Rearrange provisioning flow. Add needsMessageSync response.

// FREEBIE
This commit is contained in:
Moxie Marlinspike
2015-01-21 13:56:58 -08:00
parent d2dbff173a
commit f7132bdbbc
11 changed files with 131 additions and 51 deletions

View File

@@ -7,17 +7,11 @@ import java.security.SecureRandom;
public class ProvisioningAddress extends WebsocketAddress {
private static final String PREFIX = ">>ephemeral-";
private final String address;
public ProvisioningAddress(String address) throws InvalidWebsocketAddressException {
super(address, 0);
this.address = address;
if (address == null || !address.startsWith(PREFIX)) {
throw new InvalidWebsocketAddressException(address);
}
}
public String getAddress() {
@@ -29,8 +23,8 @@ public class ProvisioningAddress extends WebsocketAddress {
byte[] random = new byte[16];
SecureRandom.getInstance("SHA1PRNG").nextBytes(random);
return new ProvisioningAddress(PREFIX + Base64.encodeBytesWithoutPadding(random)
.replace('+', '-').replace('/', '_'));
return new ProvisioningAddress(Base64.encodeBytesWithoutPadding(random)
.replace('+', '-').replace('/', '_'));
} catch (NoSuchAlgorithmException | InvalidWebsocketAddressException e) {
throw new AssertionError(e);
}