mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-23 20:42:06 +01:00
Comments and remove getter for rpad
This commit is contained in:
parent
0900d0a27d
commit
de2cac03bd
5 changed files with 17 additions and 7 deletions
|
@ -18,6 +18,9 @@ package org.jivesoftware.smackx.ox;
|
||||||
|
|
||||||
import org.jivesoftware.smack.initializer.UrlInitializer;
|
import org.jivesoftware.smack.initializer.UrlInitializer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializer class which registers ExtensionElementProviders on startup.
|
||||||
|
*/
|
||||||
public class OpenPgpInitializer extends UrlInitializer {
|
public class OpenPgpInitializer extends UrlInitializer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -43,10 +43,6 @@ public abstract class EncryptedOpenPgpContentElement extends OpenPgpContentEleme
|
||||||
this.rpad = createRandomPadding();
|
this.rpad = createRandomPadding();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRandomPadding() {
|
|
||||||
return rpad;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String createRandomPadding() {
|
private static String createRandomPadding() {
|
||||||
SecureRandom secRan = new SecureRandom();
|
SecureRandom secRan = new SecureRandom();
|
||||||
int len = secRan.nextInt(256); // TODO: Find suitable value.
|
int len = secRan.nextInt(256); // TODO: Find suitable value.
|
||||||
|
|
|
@ -50,14 +50,26 @@ public abstract class OpenPgpContentElement implements ExtensionElement {
|
||||||
this.payload = payload;
|
this.payload = payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the set of recipients.
|
||||||
|
* @return recipients.
|
||||||
|
*/
|
||||||
public final Set<Jid> getTo() {
|
public final Set<Jid> getTo() {
|
||||||
return to;
|
return to;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the timestamp on which the encrypted element has been created.
|
||||||
|
* @return timestamp.
|
||||||
|
*/
|
||||||
public final Date getTimestamp() {
|
public final Date getTimestamp() {
|
||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the payload of the message.
|
||||||
|
* @return payload.
|
||||||
|
*/
|
||||||
public final List<ExtensionElement> getPayload() {
|
public final List<ExtensionElement> getPayload() {
|
||||||
return payload;
|
return payload;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,10 +33,12 @@ public class OpenPgpElement implements ExtensionElement {
|
||||||
public static final String ELEMENT = "openpgp";
|
public static final String ELEMENT = "openpgp";
|
||||||
public static final String NAMESPACE = "urn:xmpp:openpgp:0";
|
public static final String NAMESPACE = "urn:xmpp:openpgp:0";
|
||||||
|
|
||||||
|
// Represents the OpenPGP message, but encoded using base64.
|
||||||
private final String base64EncodedOpenPgpMessage;
|
private final String base64EncodedOpenPgpMessage;
|
||||||
|
|
||||||
private OpenPgpMessage openPgpMessage;
|
private OpenPgpMessage openPgpMessage;
|
||||||
|
|
||||||
|
// Represents the OpenPGP message, but base64 decoded.
|
||||||
private byte[] openPgpMessageBytes;
|
private byte[] openPgpMessageBytes;
|
||||||
|
|
||||||
private OpenPgpContentElement openPgpContentElement;
|
private OpenPgpContentElement openPgpContentElement;
|
||||||
|
|
|
@ -82,7 +82,6 @@ public class OpenPgpElementTest extends SmackTestSuite {
|
||||||
payload.add(new Message.Body("de", "Hallo Welt!"));
|
payload.add(new Message.Body("de", "Hallo Welt!"));
|
||||||
CryptElement element = new CryptElement(recipients, payload);
|
CryptElement element = new CryptElement(recipients, payload);
|
||||||
|
|
||||||
assertNotNull(element.getRandomPadding());
|
|
||||||
assertNotNull(element.getTimestamp());
|
assertNotNull(element.getTimestamp());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +139,6 @@ public class OpenPgpElementTest extends SmackTestSuite {
|
||||||
assertEquals(element.getTimestamp(), parsed.getTimestamp());
|
assertEquals(element.getTimestamp(), parsed.getTimestamp());
|
||||||
assertEquals(element.getTo(), parsed.getTo());
|
assertEquals(element.getTo(), parsed.getTo());
|
||||||
assertEquals(element.getPayload(), parsed.getPayload());
|
assertEquals(element.getPayload(), parsed.getPayload());
|
||||||
assertEquals(element.getRandomPadding(), parsed.getRandomPadding());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -171,7 +169,6 @@ public class OpenPgpElementTest extends SmackTestSuite {
|
||||||
assertEquals(element.getTimestamp(), parsed.getTimestamp());
|
assertEquals(element.getTimestamp(), parsed.getTimestamp());
|
||||||
assertEquals(element.getTo(), parsed.getTo());
|
assertEquals(element.getTo(), parsed.getTo());
|
||||||
assertEquals(element.getPayload(), parsed.getPayload());
|
assertEquals(element.getPayload(), parsed.getPayload());
|
||||||
assertEquals(element.getRandomPadding(), parsed.getRandomPadding());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue