mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-09 17:19:39 +02:00
Add secure(OnlineAttackSafe|Unique|OfflineAttackSafe)RandomString()
and replace usages of java.util.UUID in Smack with secureUniqueRandomString() because it uses a thread-local secure random number generator.
This commit is contained in:
parent
58fc39714f
commit
619b8e6f4a
8 changed files with 89 additions and 60 deletions
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright © 2017-2018 Florian Schmaus, 2016-2017 Fernando Ramirez
|
||||
* Copyright © 2017-2019 Florian Schmaus, 2016-2017 Fernando Ramirez
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -23,7 +23,6 @@ import java.util.Date;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import org.jivesoftware.smack.ConnectionCreationListener;
|
||||
|
@ -456,7 +455,7 @@ public final class MamManager extends Manager {
|
|||
|
||||
public MamQuery queryArchive(MamQueryArgs mamQueryArgs) throws NoResponseException, XMPPErrorException,
|
||||
NotConnectedException, NotLoggedInException, InterruptedException {
|
||||
String queryId = UUID.randomUUID().toString();
|
||||
String queryId = StringUtils.secureUniqueRandomString();
|
||||
String node = mamQueryArgs.node;
|
||||
DataForm dataForm = mamQueryArgs.getDataForm();
|
||||
|
||||
|
@ -515,7 +514,7 @@ public final class MamManager extends Manager {
|
|||
public List<FormField> retrieveFormFields(String node)
|
||||
throws NoResponseException, XMPPErrorException, NotConnectedException,
|
||||
InterruptedException, NotLoggedInException {
|
||||
String queryId = UUID.randomUUID().toString();
|
||||
String queryId = StringUtils.secureUniqueRandomString();
|
||||
MamQueryIQ mamQueryIq = new MamQueryIQ(queryId, node, null);
|
||||
mamQueryIq.setTo(archiveAddress);
|
||||
|
||||
|
@ -601,7 +600,8 @@ public final class MamManager extends Manager {
|
|||
|
||||
private List<Message> page(RSMSet requestRsmSet) throws NoResponseException, XMPPErrorException,
|
||||
NotConnectedException, NotLoggedInException, InterruptedException {
|
||||
MamQueryIQ mamQueryIQ = new MamQueryIQ(UUID.randomUUID().toString(), node, form);
|
||||
String queryId = StringUtils.secureUniqueRandomString();
|
||||
MamQueryIQ mamQueryIQ = new MamQueryIQ(queryId, node, form);
|
||||
mamQueryIQ.setType(IQ.Type.set);
|
||||
mamQueryIQ.setTo(archiveAddress);
|
||||
mamQueryIQ.addExtension(requestRsmSet);
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.sid.element;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
|
||||
|
@ -28,7 +26,7 @@ public abstract class StableAndUniqueIdElement implements ExtensionElement {
|
|||
private final String id;
|
||||
|
||||
public StableAndUniqueIdElement() {
|
||||
this.id = UUID.randomUUID().toString();
|
||||
this.id = StringUtils.secureUniqueRandomString();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
|
|
@ -65,7 +65,7 @@ public class StableUniqueStanzaIdTest extends SmackTestSuite {
|
|||
OriginIdElement element = new OriginIdElement();
|
||||
assertNotNull(element);
|
||||
assertEquals(StableUniqueStanzaIdManager.NAMESPACE, element.getNamespace());
|
||||
assertEquals(36, element.getId().length());
|
||||
assertEquals(16, element.getId().length());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue