Check that author and group names aren't empty.

This commit is contained in:
akwizgran
2014-01-31 17:23:14 +00:00
parent 93890d56f6
commit cde4ca574f
9 changed files with 26 additions and 9 deletions

View File

@@ -1,5 +1,7 @@
package org.briarproject.api;
import static org.briarproject.api.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
/** A pseudonym for a user. */
public class Author {
@@ -8,6 +10,8 @@ public class Author {
private final byte[] publicKey;
public Author(AuthorId id, String name, byte[] publicKey) {
if(name.length() == 0 || name.length() > MAX_AUTHOR_NAME_LENGTH)
throw new IllegalArgumentException();
this.id = id;
this.name = name;
this.publicKey = publicKey;

View File

@@ -10,7 +10,7 @@ public class TransportId {
private final String id;
public TransportId(String id) {
if(id.length() > MAX_TRANSPORT_ID_LENGTH || id.equals(""))
if(id.length() == 0 || id.length() > MAX_TRANSPORT_ID_LENGTH)
throw new IllegalArgumentException();
this.id = id;
}

View File

@@ -1,5 +1,8 @@
package org.briarproject.api.messaging;
import static org.briarproject.api.messaging.MessagingConstants.GROUP_SALT_LENGTH;
import static org.briarproject.api.messaging.MessagingConstants.MAX_GROUP_NAME_LENGTH;
/** A group to which users may subscribe. */
public class Group {
@@ -8,6 +11,10 @@ public class Group {
private final byte[] salt;
public Group(GroupId id, String name, byte[] salt) {
if(name.length() == 0 || name.length() > MAX_GROUP_NAME_LENGTH)
throw new IllegalArgumentException();
if(salt.length != GROUP_SALT_LENGTH)
throw new IllegalArgumentException();
this.id = id;
this.name = name;
this.salt = salt;