mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29:06 +01:00
Merge branch '700-update-blog-backend-to-match-current-usage' into 'master'
Update blog backend to match current usage Closes #700 See merge request !371
This commit is contained in:
@@ -538,7 +538,7 @@ public class BlogManagerTest extends BriarIntegrationTest {
|
||||
author0 = authorFactory
|
||||
.createLocalAuthor(AUTHOR1, publicKey0, privateKey0);
|
||||
identityManager0.addLocalAuthor(author0);
|
||||
blog0 = blogFactory.createPersonalBlog(author0);
|
||||
blog0 = blogFactory.createBlog(author0);
|
||||
|
||||
KeyPair keyPair1 = crypto.generateSignatureKeyPair();
|
||||
byte[] publicKey1 = keyPair1.getPublic().getEncoded();
|
||||
@@ -546,7 +546,7 @@ public class BlogManagerTest extends BriarIntegrationTest {
|
||||
author1 = authorFactory
|
||||
.createLocalAuthor(AUTHOR2, publicKey1, privateKey1);
|
||||
identityManager1.addLocalAuthor(author1);
|
||||
blog1 = blogFactory.createPersonalBlog(author1);
|
||||
blog1 = blogFactory.createBlog(author1);
|
||||
}
|
||||
|
||||
private void addDefaultContacts() throws DbException {
|
||||
|
||||
@@ -72,12 +72,12 @@ public class BlogSharingIntegrationTest extends BriarIntegrationTest {
|
||||
private BlogManager blogManager0, blogManager1;
|
||||
private ContactManager contactManager0, contactManager1, contactManager2;
|
||||
private Contact contact1, contact2, contact01, contact02;
|
||||
private ContactId contactId1, contactId2, contactId01, contactId02;
|
||||
private ContactId contactId1, contactId01;
|
||||
private IdentityManager identityManager0, identityManager1,
|
||||
identityManager2;
|
||||
private LocalAuthor author0, author1, author2;
|
||||
private Blog blog0, blog1, blog2;
|
||||
private SharerListener listener0, listener2;
|
||||
private SharerListener listener0;
|
||||
private InviteeListener listener1;
|
||||
|
||||
@Inject
|
||||
@@ -670,7 +670,7 @@ public class BlogSharingIntegrationTest extends BriarIntegrationTest {
|
||||
);
|
||||
contact1 = contactManager0.getContact(contactId1);
|
||||
// sharer adds second contact
|
||||
contactId2 = contactManager0.addContact(author2,
|
||||
ContactId contactId2 = contactManager0.addContact(author2,
|
||||
author0.getId(), master, clock.currentTimeMillis(), true,
|
||||
true, true
|
||||
);
|
||||
@@ -681,7 +681,7 @@ public class BlogSharingIntegrationTest extends BriarIntegrationTest {
|
||||
true, true
|
||||
);
|
||||
contact01 = contactManager1.getContact(contactId01);
|
||||
contactId02 = contactManager2.addContact(author0,
|
||||
ContactId contactId02 = contactManager2.addContact(author0,
|
||||
author2.getId(), master, clock.currentTimeMillis(), true,
|
||||
true, true
|
||||
);
|
||||
@@ -699,7 +699,7 @@ public class BlogSharingIntegrationTest extends BriarIntegrationTest {
|
||||
t0.getEventBus().addListener(listener0);
|
||||
listener1 = new InviteeListener(accept);
|
||||
t1.getEventBus().addListener(listener1);
|
||||
listener2 = new SharerListener();
|
||||
SharerListener listener2 = new SharerListener();
|
||||
t2.getEventBus().addListener(listener2);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
<dimen name="message_bubble_timestamp_margin">7dp</dimen>
|
||||
<dimen name="forum_nested_line_width">2dp</dimen>
|
||||
<dimen name="forum_nested_indicator">24dp</dimen>
|
||||
<dimen name="forum_avatar_size">20dp</dimen>
|
||||
|
||||
<dimen name="blogs_avatar_normal_size">30dp</dimen>
|
||||
<dimen name="blogs_avatar_icon_size">15dp</dimen>
|
||||
|
||||
@@ -240,25 +240,14 @@
|
||||
<string name="nobody">Nobody</string>
|
||||
|
||||
<!-- Blogs -->
|
||||
<string name="blogs_my_blogs_create">Create Blog</string>
|
||||
<string name="blogs_my_blogs_label">Add new Blog</string>
|
||||
<string name="blogs_my_blogs_create_hint_title">Blog title (cannot be changed later)</string>
|
||||
<string name="blogs_my_blogs_create_hint_desc">A short description of your new blog</string>
|
||||
<string name="blogs_my_blogs_create_hint_desc_explanation">Potential readers may or may not subscribe to your blog based on the content of the description.</string>
|
||||
<string name="blogs_my_blogs_created">Blog created</string>
|
||||
<string name="blogs_blog_is_empty">This blog is empty</string>
|
||||
<string name="blogs_other_blog_empty_state">This blog is currently empty.\n\nEither the author hasn\'t written anything yet, or the person who shared this blog with you needs to come online, so posts can be synchronized.</string>
|
||||
<string name="tag_new">NEW</string>
|
||||
<string name="read_more">read more</string>
|
||||
<string name="blogs_write_blog_post">Write Blog Post</string>
|
||||
<string name="blogs_write_blog_post_title_hint">Add a title (optional)</string>
|
||||
<string name="blogs_write_blog_post_body_hint">Type your blog post here</string>
|
||||
<string name="blogs_publish_blog_post">Publish</string>
|
||||
<string name="blogs_blog_post_created">Blog Post Created</string>
|
||||
<string name="blogs_blog_post_received">New Blog Post Received</string>
|
||||
<string name="blogs_blog_post_scroll_to">Scroll To</string>
|
||||
<string name="blogs_blog_failed_to_load">Blog failed to load</string>
|
||||
<string name="blogs_blog_post_failed_to_load">Blog post failed to load</string>
|
||||
<string name="blogs_feed_empty_state">This is the global blog feed.\n\nIt looks like nobody blogged anything, yet.\n\nBe the first and tap the pen icon to write a new blog post.</string>
|
||||
<string name="blogs_personal_blog">%s\'s Personal Blog</string>
|
||||
<string name="blogs_remove_blog">Remove Blog</string>
|
||||
@@ -268,9 +257,6 @@
|
||||
<string name="blogs_reblog_comment_hint">Add an optional comment</string>
|
||||
<string name="blogs_reblog_button">Reblog</string>
|
||||
|
||||
<string name="blogs_blog_list">Blog List</string>
|
||||
<string name="blogs_available_blogs">Available Blogs</string>
|
||||
|
||||
<!-- Blog Sharing -->
|
||||
<string name="blogs_sharing_share">Share Blog</string>
|
||||
<string name="blogs_sharing_error">There was an error sharing this blog.</string>
|
||||
@@ -353,12 +339,6 @@
|
||||
<string name="link_warning_text">This can be used to identify you. Think about whether you trust the person that sent you this link and consider opening it with Orfox.</string>
|
||||
<string name="link_warning_open_link">Open Link</string>
|
||||
|
||||
<!-- Multiple Identities -->
|
||||
<string name="anonymous">Anonymous</string>
|
||||
<string name="new_identity_title">New Identity</string>
|
||||
<string name="create_identity_button">Create Identity</string>
|
||||
<string name="identity_created_toast">Identity created</string>
|
||||
|
||||
<!-- Crash Reporter -->
|
||||
<string name="crash_report_title">Briar Crash Report</string>
|
||||
<string name="briar_crashed">Sorry, Briar has crashed.</string>
|
||||
|
||||
@@ -59,17 +59,6 @@
|
||||
<item name="android:textColor">@android:color/primary_text_light</item>
|
||||
</style>
|
||||
|
||||
<style name="BriarTag">
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:layout_marginRight">@dimen/margin_medium</item>
|
||||
<item name="android:paddingLeft">3dp</item>
|
||||
<item name="android:paddingRight">3dp</item>
|
||||
<item name="android:background">@color/briar_primary</item>
|
||||
<item name="android:textSize">@dimen/text_size_tiny</item>
|
||||
<item name="android:textColor">@color/briar_text_primary_inverse</item>
|
||||
</style>
|
||||
|
||||
<style name="Divider">
|
||||
<item name="android:background">@color/divider</item>
|
||||
</style>
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.briarproject.android.blogs;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.ActivityComponent;
|
||||
@@ -18,8 +17,6 @@ public class BlogActivity extends BriarActivity implements
|
||||
|
||||
static final int REQUEST_WRITE_POST = 1;
|
||||
static final int REQUEST_SHARE = 2;
|
||||
static final String BLOG_NAME = "briar.BLOG_NAME";
|
||||
static final String IS_NEW_BLOG = "briar.IS_NEW_BLOG";
|
||||
|
||||
@Inject
|
||||
BlogController blogController;
|
||||
@@ -35,17 +32,10 @@ public class BlogActivity extends BriarActivity implements
|
||||
GroupId groupId = new GroupId(b);
|
||||
blogController.setGroupId(groupId);
|
||||
|
||||
// Name of the blog
|
||||
String blogName = i.getStringExtra(BLOG_NAME);
|
||||
if (blogName != null) setTitle(blogName);
|
||||
|
||||
// Was this blog just created?
|
||||
boolean isNew = i.getBooleanExtra(IS_NEW_BLOG, false);
|
||||
|
||||
setContentView(R.layout.activity_fragment_container);
|
||||
|
||||
if (state == null) {
|
||||
BlogFragment f = BlogFragment.newInstance(groupId, blogName, isNew);
|
||||
BlogFragment f = BlogFragment.newInstance(groupId);
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.fragmentContainer, f, f.getUniqueTag())
|
||||
.commit();
|
||||
|
||||
@@ -38,12 +38,9 @@ import javax.inject.Inject;
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;
|
||||
import static android.support.design.widget.Snackbar.LENGTH_LONG;
|
||||
import static android.support.v4.app.ActivityOptionsCompat.makeCustomAnimation;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static org.briarproject.android.BriarActivity.GROUP_ID;
|
||||
import static org.briarproject.android.blogs.BlogActivity.BLOG_NAME;
|
||||
import static org.briarproject.android.blogs.BlogActivity.IS_NEW_BLOG;
|
||||
import static org.briarproject.android.blogs.BlogActivity.REQUEST_SHARE;
|
||||
import static org.briarproject.android.blogs.BlogActivity.REQUEST_WRITE_POST;
|
||||
|
||||
@@ -56,21 +53,17 @@ public class BlogFragment extends BaseFragment implements
|
||||
BlogController blogController;
|
||||
|
||||
private GroupId groupId;
|
||||
private String blogName;
|
||||
private BlogPostAdapter adapter;
|
||||
private BriarRecyclerView list;
|
||||
private MenuItem writeButton, deleteButton;
|
||||
private boolean isMyBlog = false, canDeleteBlog = false;
|
||||
|
||||
static BlogFragment newInstance(GroupId groupId, @Nullable String name,
|
||||
boolean isNew) {
|
||||
static BlogFragment newInstance(GroupId groupId) {
|
||||
|
||||
BlogFragment f = new BlogFragment();
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putByteArray(GROUP_ID, groupId.getBytes());
|
||||
bundle.putString(BLOG_NAME, name);
|
||||
bundle.putBoolean(IS_NEW_BLOG, isNew);
|
||||
|
||||
f.setArguments(bundle);
|
||||
return f;
|
||||
@@ -84,8 +77,6 @@ public class BlogFragment extends BaseFragment implements
|
||||
byte[] b = args.getByteArray(GROUP_ID);
|
||||
if (b == null) throw new IllegalStateException("No group ID in args");
|
||||
groupId = new GroupId(b);
|
||||
blogName = args.getString(BLOG_NAME);
|
||||
boolean isNew = args.getBoolean(IS_NEW_BLOG);
|
||||
|
||||
View v = inflater.inflate(R.layout.fragment_blog, container, false);
|
||||
|
||||
@@ -97,16 +88,6 @@ public class BlogFragment extends BaseFragment implements
|
||||
list.showProgressBar();
|
||||
list.setEmptyText(getString(R.string.blogs_other_blog_empty_state));
|
||||
|
||||
// show snackbar if this blog was just created
|
||||
if (isNew) {
|
||||
Snackbar s = Snackbar.make(list, R.string.blogs_my_blogs_created,
|
||||
LENGTH_LONG);
|
||||
s.getView().setBackgroundResource(R.color.briar_primary);
|
||||
s.show();
|
||||
|
||||
// show only once
|
||||
args.putBoolean(IS_NEW_BLOG, false);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -152,7 +133,6 @@ public class BlogFragment extends BaseFragment implements
|
||||
Intent i = new Intent(getActivity(),
|
||||
WriteBlogPostActivity.class);
|
||||
i.putExtra(GROUP_ID, groupId.getBytes());
|
||||
i.putExtra(BLOG_NAME, blogName);
|
||||
startActivityForResult(i, REQUEST_WRITE_POST,
|
||||
options.toBundle());
|
||||
return true;
|
||||
@@ -266,10 +246,6 @@ public class BlogFragment extends BaseFragment implements
|
||||
private void setToolbarTitle(Author a) {
|
||||
String title = getString(R.string.blogs_personal_blog, a.getName());
|
||||
getActivity().setTitle(title);
|
||||
|
||||
// safe title in intent, so it can be restored automatically
|
||||
Intent intent = getActivity().getIntent();
|
||||
intent.putExtra(BLOG_NAME, title);
|
||||
}
|
||||
|
||||
private void showWriteButton() {
|
||||
|
||||
@@ -17,10 +17,6 @@ class BlogItem {
|
||||
return blog;
|
||||
}
|
||||
|
||||
String getName() {
|
||||
return blog.getName();
|
||||
}
|
||||
|
||||
boolean isOurs() {
|
||||
return ours;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ import static android.app.Activity.RESULT_OK;
|
||||
import static android.support.design.widget.Snackbar.LENGTH_LONG;
|
||||
import static android.support.v4.app.ActivityOptionsCompat.makeCustomAnimation;
|
||||
import static org.briarproject.android.BriarActivity.GROUP_ID;
|
||||
import static org.briarproject.android.blogs.BlogActivity.BLOG_NAME;
|
||||
import static org.briarproject.android.blogs.BlogActivity.REQUEST_WRITE_POST;
|
||||
|
||||
public class FeedFragment extends BaseFragment implements
|
||||
@@ -171,7 +170,6 @@ public class FeedFragment extends BaseFragment implements
|
||||
Intent i1 =
|
||||
new Intent(getActivity(), WriteBlogPostActivity.class);
|
||||
i1.putExtra(GROUP_ID, personalBlog.getId().getBytes());
|
||||
i1.putExtra(BLOG_NAME, personalBlog.getName());
|
||||
startActivityForResult(i1, REQUEST_WRITE_POST,
|
||||
options.toBundle());
|
||||
return true;
|
||||
|
||||
@@ -5,7 +5,6 @@ import org.briarproject.api.identity.Author;
|
||||
import org.briarproject.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.api.sharing.Shareable;
|
||||
import org.briarproject.api.sync.Group;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@@ -13,21 +12,13 @@ import javax.annotation.concurrent.Immutable;
|
||||
@NotNullByDefault
|
||||
public class Blog extends BaseGroup implements Shareable {
|
||||
|
||||
private final String description;
|
||||
private final Author author;
|
||||
|
||||
public Blog(Group group, String name, String description, Author author) {
|
||||
super(group, name);
|
||||
this.description = description;
|
||||
public Blog(Group group, Author author) {
|
||||
super(group);
|
||||
this.author = author;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Author getAuthor() {
|
||||
return author;
|
||||
}
|
||||
@@ -36,4 +27,13 @@ public class Blog extends BaseGroup implements Shareable {
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof Blog && super.equals(o);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the blog's author's name, not the name as shown in the UI.
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return author.getName();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,12 +16,7 @@ public interface BlogConstants {
|
||||
/** The maximum length of a blog comment in bytes. */
|
||||
int MAX_BLOG_COMMENT_LENGTH = MAX_BLOG_POST_BODY_LENGTH;
|
||||
|
||||
/** The internal name of personal blogs that are created automatically */
|
||||
String PERSONAL_BLOG_NAME = "briar.PERSONAL_BLOG_NAME";
|
||||
|
||||
/* Blog Sharing Constants */
|
||||
String BLOG_TITLE = "blogTitle";
|
||||
String BLOG_DESC = "blogDescription";
|
||||
String BLOG_AUTHOR_NAME = "blogAuthorName";
|
||||
String BLOG_PUBLIC_KEY = "blogPublicKey";
|
||||
|
||||
|
||||
@@ -2,19 +2,17 @@ package org.briarproject.api.blogs;
|
||||
|
||||
import org.briarproject.api.FormatException;
|
||||
import org.briarproject.api.identity.Author;
|
||||
import org.briarproject.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.api.sync.Group;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@NotNullByDefault
|
||||
public interface BlogFactory {
|
||||
|
||||
/** Creates a blog with the given name, description and author. */
|
||||
Blog createBlog(@NotNull String name, @NotNull String description,
|
||||
@NotNull Author author);
|
||||
|
||||
/** Creates a personal blog for a given author. */
|
||||
Blog createPersonalBlog(@NotNull Author author);
|
||||
Blog createBlog(Author author);
|
||||
|
||||
/** Parses a blog with the given Group */
|
||||
Blog parseBlog(@NotNull Group g) throws FormatException;
|
||||
|
||||
/** Parses a blog with the given Group and description */
|
||||
Blog parseBlog(@NotNull Group g, @NotNull String description)
|
||||
throws FormatException;
|
||||
}
|
||||
|
||||
@@ -16,10 +16,6 @@ public interface BlogManager {
|
||||
/** Returns the unique ID of the blog client. */
|
||||
ClientId getClientId();
|
||||
|
||||
/** Creates a new Blog. */
|
||||
Blog addBlog(LocalAuthor localAuthor, String name, String description)
|
||||
throws DbException;
|
||||
|
||||
/** Returns true if a blog can be removed. */
|
||||
boolean canBeRemoved(GroupId g) throws DbException;
|
||||
|
||||
|
||||
@@ -8,9 +8,7 @@ import org.briarproject.api.sharing.SharingMessage.Invitation;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
|
||||
import static org.briarproject.api.blogs.BlogConstants.BLOG_AUTHOR_NAME;
|
||||
import static org.briarproject.api.blogs.BlogConstants.BLOG_DESC;
|
||||
import static org.briarproject.api.blogs.BlogConstants.BLOG_PUBLIC_KEY;
|
||||
import static org.briarproject.api.blogs.BlogConstants.BLOG_TITLE;
|
||||
import static org.briarproject.api.sharing.SharingConstants.INVITATION_MSG;
|
||||
import static org.briarproject.api.sharing.SharingConstants.SESSION_ID;
|
||||
import static org.briarproject.api.sharing.SharingConstants.TIME;
|
||||
@@ -19,19 +17,14 @@ public interface BlogSharingMessage {
|
||||
|
||||
class BlogInvitation extends Invitation {
|
||||
|
||||
private final String blogTitle;
|
||||
private final String blogDesc;
|
||||
private final String blogAuthorName;
|
||||
private final byte[] blogPublicKey;
|
||||
|
||||
public BlogInvitation(GroupId groupId, SessionId sessionId,
|
||||
String blogTitle, String blogDesc, String blogAuthorName,
|
||||
byte[] blogPublicKey, long time, String message) {
|
||||
|
||||
String blogAuthorName, byte[] blogPublicKey, long time,
|
||||
String message) {
|
||||
super(groupId, sessionId, time, message);
|
||||
|
||||
this.blogTitle = blogTitle;
|
||||
this.blogDesc = blogDesc;
|
||||
this.blogAuthorName = blogAuthorName;
|
||||
this.blogPublicKey = blogPublicKey;
|
||||
}
|
||||
@@ -39,8 +32,6 @@ public interface BlogSharingMessage {
|
||||
@Override
|
||||
public BdfList toBdfList() {
|
||||
BdfList list = super.toBdfList();
|
||||
list.add(blogTitle);
|
||||
list.add(blogDesc);
|
||||
list.add(BdfList.of(blogAuthorName, blogPublicKey));
|
||||
if (message != null) list.add(message);
|
||||
return list;
|
||||
@@ -49,8 +40,6 @@ public interface BlogSharingMessage {
|
||||
@Override
|
||||
public BdfDictionary toBdfDictionary() {
|
||||
BdfDictionary d = toBdfDictionaryHelper();
|
||||
d.put(BLOG_TITLE, blogTitle);
|
||||
d.put(BLOG_DESC, blogDesc);
|
||||
d.put(BLOG_AUTHOR_NAME, blogAuthorName);
|
||||
d.put(BLOG_PUBLIC_KEY, blogPublicKey);
|
||||
if (message != null) d.put(INVITATION_MSG, message);
|
||||
@@ -61,23 +50,13 @@ public interface BlogSharingMessage {
|
||||
throws FormatException {
|
||||
|
||||
SessionId sessionId = new SessionId(d.getRaw(SESSION_ID));
|
||||
String blogTitle = d.getString(BLOG_TITLE);
|
||||
String blogDesc = d.getString(BLOG_DESC);
|
||||
String blogAuthorName = d.getString(BLOG_AUTHOR_NAME);
|
||||
byte[] blogPublicKey = d.getRaw(BLOG_PUBLIC_KEY);
|
||||
String message = d.getOptionalString(INVITATION_MSG);
|
||||
long time = d.getLong(TIME);
|
||||
|
||||
return new BlogInvitation(groupId, sessionId, blogTitle,
|
||||
blogDesc, blogAuthorName, blogPublicKey, time, message);
|
||||
}
|
||||
|
||||
public String getBlogTitle() {
|
||||
return blogTitle;
|
||||
}
|
||||
|
||||
public String getBlogDesc() {
|
||||
return blogDesc;
|
||||
return new BlogInvitation(groupId, sessionId, blogAuthorName,
|
||||
blogPublicKey, time, message);
|
||||
}
|
||||
|
||||
public String getBlogAuthorName() {
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.briarproject.api.clients;
|
||||
import org.briarproject.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.api.sync.Group;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@@ -12,28 +11,19 @@ import javax.annotation.concurrent.Immutable;
|
||||
public abstract class BaseGroup {
|
||||
|
||||
private final Group group;
|
||||
private final String name;
|
||||
|
||||
public BaseGroup(Group group, String name) {
|
||||
public BaseGroup(Group group) {
|
||||
this.group = group;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public GroupId getId() {
|
||||
return group.getId();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Group getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return group.hashCode();
|
||||
|
||||
@@ -10,13 +10,19 @@ import javax.annotation.concurrent.Immutable;
|
||||
@NotNullByDefault
|
||||
public abstract class NamedGroup extends BaseGroup {
|
||||
|
||||
private final String name;
|
||||
private final byte[] salt;
|
||||
|
||||
public NamedGroup(@NotNull Group group, @NotNull String name, byte[] salt) {
|
||||
super(group, name);
|
||||
super(group);
|
||||
this.name = name;
|
||||
this.salt = salt;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public byte[] getSalt() {
|
||||
return salt;
|
||||
}
|
||||
|
||||
@@ -3,17 +3,12 @@ package org.briarproject.api.event;
|
||||
import org.briarproject.api.blogs.BlogInvitationResponse;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
|
||||
public class BlogInvitationResponseReceivedEvent extends InvitationResponseReceivedEvent {
|
||||
public class BlogInvitationResponseReceivedEvent
|
||||
extends InvitationResponseReceivedEvent {
|
||||
|
||||
private final String blogTitle;
|
||||
|
||||
public BlogInvitationResponseReceivedEvent(String blogTitle,
|
||||
ContactId contactId, BlogInvitationResponse response) {
|
||||
public BlogInvitationResponseReceivedEvent(ContactId contactId,
|
||||
BlogInvitationResponse response) {
|
||||
super(contactId, response);
|
||||
this.blogTitle = blogTitle;
|
||||
}
|
||||
|
||||
public String getBlogTitle() {
|
||||
return blogTitle;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,14 +7,14 @@ import org.briarproject.api.clients.ClientHelper;
|
||||
import org.briarproject.api.data.BdfList;
|
||||
import org.briarproject.api.identity.Author;
|
||||
import org.briarproject.api.identity.AuthorFactory;
|
||||
import org.briarproject.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.api.sync.Group;
|
||||
import org.briarproject.api.sync.GroupFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.briarproject.api.blogs.BlogConstants.PERSONAL_BLOG_NAME;
|
||||
|
||||
@NotNullByDefault
|
||||
class BlogFactoryImpl implements BlogFactory {
|
||||
|
||||
private final GroupFactory groupFactory;
|
||||
@@ -31,39 +31,29 @@ class BlogFactoryImpl implements BlogFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Blog createPersonalBlog(@NotNull Author a) {
|
||||
return createBlog(PERSONAL_BLOG_NAME, "", a);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Blog createBlog(@NotNull String name, @NotNull String description,
|
||||
@NotNull Author author) {
|
||||
public Blog createBlog(Author a) {
|
||||
try {
|
||||
BdfList blog = BdfList.of(
|
||||
name,
|
||||
author.getName(),
|
||||
author.getPublicKey()
|
||||
a.getName(),
|
||||
a.getPublicKey()
|
||||
);
|
||||
byte[] descriptor = clientHelper.toByteArray(blog);
|
||||
Group g = groupFactory
|
||||
.createGroup(BlogManagerImpl.CLIENT_ID, descriptor);
|
||||
return new Blog(g, name, description, author);
|
||||
return new Blog(g, a);
|
||||
} catch (FormatException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Blog parseBlog(@NotNull Group g, @NotNull String description)
|
||||
throws FormatException {
|
||||
|
||||
public Blog parseBlog(@NotNull Group g) throws FormatException {
|
||||
byte[] descriptor = g.getDescriptor();
|
||||
// Blog Name, Author Name, Public Key
|
||||
// Author Name, Public Key
|
||||
BdfList blog = clientHelper.toList(descriptor);
|
||||
String name = blog.getString(0);
|
||||
Author a =
|
||||
authorFactory.createAuthor(blog.getString(1), blog.getRaw(2));
|
||||
return new Blog(g, name, description, a);
|
||||
authorFactory.createAuthor(blog.getString(0), blog.getRaw(1));
|
||||
return new Blog(g, a);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -58,7 +58,6 @@ import static org.briarproject.api.blogs.BlogConstants.KEY_AUTHOR;
|
||||
import static org.briarproject.api.blogs.BlogConstants.KEY_AUTHOR_ID;
|
||||
import static org.briarproject.api.blogs.BlogConstants.KEY_AUTHOR_NAME;
|
||||
import static org.briarproject.api.blogs.BlogConstants.KEY_COMMENT;
|
||||
import static org.briarproject.api.blogs.BlogConstants.KEY_DESCRIPTION;
|
||||
import static org.briarproject.api.blogs.BlogConstants.KEY_ORIGINAL_MSG_ID;
|
||||
import static org.briarproject.api.blogs.BlogConstants.KEY_ORIGINAL_PARENT_MSG_ID;
|
||||
import static org.briarproject.api.blogs.BlogConstants.KEY_PARENT_MSG_ID;
|
||||
@@ -113,16 +112,14 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
||||
|
||||
@Override
|
||||
public void createLocalState(Transaction txn) throws DbException {
|
||||
// Ensure every identity does have its own personal blog
|
||||
// TODO this can probably be removed once #446 is resolved and all users migrated to a new version
|
||||
for (LocalAuthor a : db.getLocalAuthors(txn)) {
|
||||
Blog b = blogFactory.createPersonalBlog(a);
|
||||
Group g = b.getGroup();
|
||||
if (!db.containsGroup(txn, g.getId())) {
|
||||
db.addGroup(txn, g);
|
||||
for (ContactId c : db.getContacts(txn, a.getId())) {
|
||||
db.setVisibleToContact(txn, c, g.getId(), true);
|
||||
}
|
||||
// Ensure that the local identity has its own personal blog
|
||||
LocalAuthor la = identityManager.getLocalAuthor(txn);
|
||||
Blog b = blogFactory.createBlog(la);
|
||||
Group g = b.getGroup();
|
||||
if (!db.containsGroup(txn, g.getId())) {
|
||||
db.addGroup(txn, g);
|
||||
for (ContactId c : db.getContacts(txn, la.getId())) {
|
||||
db.setVisibleToContact(txn, c, g.getId(), true);
|
||||
}
|
||||
}
|
||||
// Ensure that we have the personal blogs of all pre-existing contacts
|
||||
@@ -132,7 +129,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
||||
@Override
|
||||
public void addingContact(Transaction txn, Contact c) throws DbException {
|
||||
// get personal blog of the contact
|
||||
Blog b = blogFactory.createPersonalBlog(c.getAuthor());
|
||||
Blog b = blogFactory.createBlog(c.getAuthor());
|
||||
Group g = b.getGroup();
|
||||
if (!db.containsGroup(txn, g.getId())) {
|
||||
// add the personal blog of the contact
|
||||
@@ -141,7 +138,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
||||
|
||||
// share our personal blog with the new contact
|
||||
LocalAuthor a = db.getLocalAuthor(txn, c.getLocalAuthorId());
|
||||
Blog b2 = blogFactory.createPersonalBlog(a);
|
||||
Blog b2 = blogFactory.createBlog(a);
|
||||
db.setVisibleToContact(txn, c.getId(), b2.getId(), true);
|
||||
}
|
||||
}
|
||||
@@ -149,7 +146,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
||||
@Override
|
||||
public void removingContact(Transaction txn, Contact c) throws DbException {
|
||||
if (c != null) {
|
||||
Blog b = blogFactory.createPersonalBlog(c.getAuthor());
|
||||
Blog b = blogFactory.createBlog(c.getAuthor());
|
||||
db.removeGroup(txn, b.getGroup());
|
||||
}
|
||||
}
|
||||
@@ -160,7 +157,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
||||
|
||||
// add a personal blog for the new identity
|
||||
LOG.info("New Personal Blog Added.");
|
||||
Blog b = blogFactory.createPersonalBlog(a);
|
||||
Blog b = blogFactory.createBlog(a);
|
||||
db.addGroup(txn, b.getGroup());
|
||||
}
|
||||
|
||||
@@ -169,7 +166,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
||||
throws DbException {
|
||||
|
||||
// remove the personal blog of that identity
|
||||
Blog b = blogFactory.createPersonalBlog(a);
|
||||
Blog b = blogFactory.createBlog(a);
|
||||
db.removeGroup(txn, b.getGroup());
|
||||
}
|
||||
|
||||
@@ -219,29 +216,6 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Blog addBlog(LocalAuthor localAuthor, String name,
|
||||
String description) throws DbException {
|
||||
|
||||
Blog b = blogFactory
|
||||
.createBlog(name, description, localAuthor);
|
||||
BdfDictionary metadata = BdfDictionary.of(
|
||||
new BdfEntry(KEY_DESCRIPTION, b.getDescription())
|
||||
);
|
||||
|
||||
Transaction txn = db.startTransaction(false);
|
||||
try {
|
||||
db.addGroup(txn, b.getGroup());
|
||||
clientHelper.mergeGroupMetadata(txn, b.getId(), metadata);
|
||||
txn.setComplete();
|
||||
} catch (FormatException e) {
|
||||
throw new DbException(e);
|
||||
} finally {
|
||||
db.endTransaction(txn);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeRemoved(GroupId g) throws DbException {
|
||||
Transaction txn = db.startTransaction(true);
|
||||
@@ -453,8 +427,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
||||
public Blog getBlog(Transaction txn, GroupId g) throws DbException {
|
||||
try {
|
||||
Group group = db.getGroup(txn, g);
|
||||
String description = getBlogDescription(txn, g);
|
||||
return blogFactory.parseBlog(group, description);
|
||||
return blogFactory.parseBlog(group);
|
||||
} catch (FormatException e) {
|
||||
throw new DbException(e);
|
||||
}
|
||||
@@ -476,7 +449,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
||||
|
||||
@Override
|
||||
public Blog getPersonalBlog(Author author) {
|
||||
return blogFactory.createPersonalBlog(author);
|
||||
return blogFactory.createBlog(author);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -488,8 +461,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
||||
try {
|
||||
groups = db.getGroups(txn, CLIENT_ID);
|
||||
for (Group g : groups) {
|
||||
String description = getBlogDescription(txn, g.getId());
|
||||
blogs.add(blogFactory.parseBlog(g, description));
|
||||
blogs.add(blogFactory.parseBlog(g));
|
||||
}
|
||||
txn.setComplete();
|
||||
} finally {
|
||||
@@ -613,12 +585,6 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
||||
removeHooks.add(hook);
|
||||
}
|
||||
|
||||
private String getBlogDescription(Transaction txn, GroupId g)
|
||||
throws DbException, FormatException {
|
||||
BdfDictionary d = clientHelper.getGroupMetadataAsDictionary(txn, g);
|
||||
return d.getString(KEY_DESCRIPTION, "");
|
||||
}
|
||||
|
||||
private BlogPostHeader getPostHeaderFromMetadata(Transaction txn,
|
||||
GroupId groupId, MessageId id) throws DbException, FormatException {
|
||||
BdfDictionary meta =
|
||||
|
||||
@@ -100,7 +100,7 @@ class BlogPostValidator extends BdfMessageValidator {
|
||||
byte[] sig = body.getRaw(1);
|
||||
checkLength(sig, 1, MAX_SIGNATURE_LENGTH);
|
||||
BdfList signed = BdfList.of(g.getId(), m.getTimestamp(), postBody);
|
||||
Blog b = blogFactory.parseBlog(g, ""); // description doesn't matter
|
||||
Blog b = blogFactory.parseBlog(g);
|
||||
Author a = b.getAuthor();
|
||||
try {
|
||||
clientHelper.verifySignature(sig, a.getPublicKey(), signed);
|
||||
@@ -145,7 +145,7 @@ class BlogPostValidator extends BdfMessageValidator {
|
||||
BdfList signed =
|
||||
BdfList.of(g.getId(), m.getTimestamp(), comment, pOriginalId,
|
||||
currentId);
|
||||
Blog b = blogFactory.parseBlog(g, ""); // description doesn't matter
|
||||
Blog b = blogFactory.parseBlog(g);
|
||||
Author a = b.getAuthor();
|
||||
try {
|
||||
clientHelper.verifySignature(sig, a.getPublicKey(), signed);
|
||||
|
||||
@@ -3,53 +3,40 @@ package org.briarproject.sharing;
|
||||
import org.briarproject.api.clients.SessionId;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.data.BdfDictionary;
|
||||
import org.briarproject.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.annotation.concurrent.NotThreadSafe;
|
||||
|
||||
import static org.briarproject.api.blogs.BlogConstants.BLOG_AUTHOR_NAME;
|
||||
import static org.briarproject.api.blogs.BlogConstants.BLOG_DESC;
|
||||
import static org.briarproject.api.blogs.BlogConstants.BLOG_PUBLIC_KEY;
|
||||
import static org.briarproject.api.blogs.BlogConstants.BLOG_TITLE;
|
||||
|
||||
@NotThreadSafe
|
||||
@NotNullByDefault
|
||||
public class BlogInviteeSessionState extends InviteeSessionState {
|
||||
|
||||
private final String blogTitle;
|
||||
private final String blogDesc;
|
||||
private final String blogAuthorName;
|
||||
private final byte[] blogPublicKey;
|
||||
|
||||
public BlogInviteeSessionState(SessionId sessionId, MessageId storageId,
|
||||
GroupId groupId, State state, ContactId contactId, GroupId blogId,
|
||||
String blogTitle, String blogDesc, String blogAuthorName,
|
||||
byte[] blogPublicKey, @NotNull MessageId invitationId) {
|
||||
String blogAuthorName, byte[] blogPublicKey,
|
||||
@NotNull MessageId invitationId) {
|
||||
super(sessionId, storageId, groupId, state, contactId, blogId,
|
||||
invitationId);
|
||||
|
||||
this.blogTitle = blogTitle;
|
||||
this.blogDesc = blogDesc;
|
||||
this.blogAuthorName = blogAuthorName;
|
||||
this.blogPublicKey = blogPublicKey;
|
||||
}
|
||||
|
||||
public BdfDictionary toBdfDictionary() {
|
||||
BdfDictionary d = super.toBdfDictionary();
|
||||
d.put(BLOG_TITLE, getBlogTitle());
|
||||
d.put(BLOG_DESC, getBlogDesc());
|
||||
d.put(BLOG_AUTHOR_NAME, getBlogAuthorName());
|
||||
d.put(BLOG_PUBLIC_KEY, getBlogPublicKey());
|
||||
return d;
|
||||
}
|
||||
|
||||
public String getBlogTitle() {
|
||||
return blogTitle;
|
||||
}
|
||||
|
||||
public String getBlogDesc() {
|
||||
return blogDesc;
|
||||
}
|
||||
|
||||
public String getBlogAuthorName() {
|
||||
return blogAuthorName;
|
||||
}
|
||||
|
||||
@@ -3,52 +3,41 @@ package org.briarproject.sharing;
|
||||
import org.briarproject.api.clients.SessionId;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.data.BdfDictionary;
|
||||
import org.briarproject.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import static org.briarproject.api.blogs.BlogConstants.BLOG_AUTHOR_NAME;
|
||||
import static org.briarproject.api.blogs.BlogConstants.BLOG_DESC;
|
||||
import static org.briarproject.api.blogs.BlogConstants.BLOG_PUBLIC_KEY;
|
||||
import static org.briarproject.api.blogs.BlogConstants.BLOG_TITLE;
|
||||
import javax.annotation.concurrent.NotThreadSafe;
|
||||
|
||||
import static org.briarproject.api.blogs.BlogConstants.BLOG_AUTHOR_NAME;
|
||||
import static org.briarproject.api.blogs.BlogConstants.BLOG_PUBLIC_KEY;
|
||||
|
||||
@NotThreadSafe
|
||||
@NotNullByDefault
|
||||
public class BlogSharerSessionState extends SharerSessionState {
|
||||
|
||||
private final String blogTitle;
|
||||
private final String blogDesc;
|
||||
private final String blogAuthorName;
|
||||
private final byte[] blogPublicKey;
|
||||
|
||||
public BlogSharerSessionState(SessionId sessionId, MessageId storageId,
|
||||
GroupId groupId, State state, ContactId contactId, GroupId blogId,
|
||||
String blogTitle, String blogDesc, String blogAuthorName,
|
||||
byte[] blogPublicKey, @Nullable MessageId responseId) {
|
||||
String blogAuthorName,byte[] blogPublicKey,
|
||||
@Nullable MessageId responseId) {
|
||||
super(sessionId, storageId, groupId, state, contactId, blogId,
|
||||
responseId);
|
||||
|
||||
this.blogTitle = blogTitle;
|
||||
this.blogDesc = blogDesc;
|
||||
this.blogAuthorName = blogAuthorName;
|
||||
this.blogPublicKey = blogPublicKey;
|
||||
}
|
||||
|
||||
public BdfDictionary toBdfDictionary() {
|
||||
BdfDictionary d = super.toBdfDictionary();
|
||||
d.put(BLOG_TITLE, getBlogTitle());
|
||||
d.put(BLOG_DESC, getBlogDesc());
|
||||
d.put(BLOG_AUTHOR_NAME, getBlogAuthorName());
|
||||
d.put(BLOG_PUBLIC_KEY, getBlogPublicKey());
|
||||
return d;
|
||||
}
|
||||
|
||||
public String getBlogTitle() {
|
||||
return blogTitle;
|
||||
}
|
||||
|
||||
public String getBlogDesc() {
|
||||
return blogDesc;
|
||||
}
|
||||
|
||||
public String getBlogAuthorName() {
|
||||
return blogAuthorName;
|
||||
}
|
||||
|
||||
@@ -40,9 +40,7 @@ import java.security.SecureRandom;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.briarproject.api.blogs.BlogConstants.BLOG_AUTHOR_NAME;
|
||||
import static org.briarproject.api.blogs.BlogConstants.BLOG_DESC;
|
||||
import static org.briarproject.api.blogs.BlogConstants.BLOG_PUBLIC_KEY;
|
||||
import static org.briarproject.api.blogs.BlogConstants.BLOG_TITLE;
|
||||
import static org.briarproject.api.sharing.SharingConstants.INVITATION_ID;
|
||||
import static org.briarproject.api.sharing.SharingConstants.RESPONSE_ID;
|
||||
|
||||
@@ -54,8 +52,7 @@ class BlogSharingManagerImpl extends
|
||||
"bee438b5de0b3a685badc4e49d76e72d"
|
||||
+ "21e01c4b569a775112756bdae267a028"));
|
||||
|
||||
@Inject
|
||||
IdentityManager identityManager;
|
||||
private final IdentityManager identityManager;
|
||||
private final BlogManager blogManager;
|
||||
|
||||
private final SFactory sFactory;
|
||||
@@ -70,12 +67,14 @@ class BlogSharingManagerImpl extends
|
||||
BlogManager blogManager, ClientHelper clientHelper, Clock clock,
|
||||
DatabaseComponent db, MessageQueueManager messageQueueManager,
|
||||
MetadataEncoder metadataEncoder, MetadataParser metadataParser,
|
||||
ContactGroupFactory contactGroupFactory, SecureRandom random) {
|
||||
ContactGroupFactory contactGroupFactory, SecureRandom random,
|
||||
IdentityManager identityManager) {
|
||||
|
||||
super(db, messageQueueManager, clientHelper, metadataParser,
|
||||
metadataEncoder, random, contactGroupFactory, clock);
|
||||
|
||||
this.blogManager = blogManager;
|
||||
this.identityManager = identityManager;
|
||||
sFactory = new SFactory(authorFactory, blogFactory, blogManager);
|
||||
iFactory = new IFactory();
|
||||
isFactory = new ISFactory();
|
||||
@@ -175,9 +174,12 @@ class BlogSharingManagerImpl extends
|
||||
|
||||
@Override
|
||||
public BdfList encode(Blog f) {
|
||||
return BdfList.of(f.getName(), f.getDescription(),
|
||||
BdfList.of(f.getAuthor().getName(),
|
||||
f.getAuthor().getPublicKey()));
|
||||
return BdfList.of(
|
||||
BdfList.of(
|
||||
f.getAuthor().getName(),
|
||||
f.getAuthor().getPublicKey()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -189,19 +191,16 @@ class BlogSharingManagerImpl extends
|
||||
@Override
|
||||
public Blog parse(BdfList shareable) throws FormatException {
|
||||
Author author = authorFactory
|
||||
.createAuthor(shareable.getList(2).getString(0),
|
||||
shareable.getList(2).getRaw(1));
|
||||
return blogFactory
|
||||
.createBlog(shareable.getString(0), shareable.getString(1),
|
||||
author);
|
||||
.createAuthor(shareable.getList(0).getString(0),
|
||||
shareable.getList(0).getRaw(1));
|
||||
return blogFactory.createBlog(author);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Blog parse(BlogInvitation msg) {
|
||||
Author author = authorFactory.createAuthor(msg.getBlogAuthorName(),
|
||||
msg.getBlogPublicKey());
|
||||
return blogFactory
|
||||
.createBlog(msg.getBlogTitle(), msg.getBlogDesc(), author);
|
||||
return blogFactory.createBlog(author);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -209,9 +208,7 @@ class BlogSharingManagerImpl extends
|
||||
Author author = authorFactory
|
||||
.createAuthor(state.getBlogAuthorName(),
|
||||
state.getBlogPublicKey());
|
||||
return blogFactory
|
||||
.createBlog(state.getBlogTitle(), state.getBlogDesc(),
|
||||
author);
|
||||
return blogFactory.createBlog(author);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -219,9 +216,7 @@ class BlogSharingManagerImpl extends
|
||||
Author author = authorFactory
|
||||
.createAuthor(state.getBlogAuthorName(),
|
||||
state.getBlogPublicKey());
|
||||
return blogFactory
|
||||
.createBlog(state.getBlogTitle(), state.getBlogDesc(),
|
||||
author);
|
||||
return blogFactory.createBlog(author);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,8 +232,7 @@ class BlogSharingManagerImpl extends
|
||||
public BlogInvitation build(BlogSharerSessionState localState,
|
||||
long time) {
|
||||
return new BlogInvitation(localState.getGroupId(),
|
||||
localState.getSessionId(), localState.getBlogTitle(),
|
||||
localState.getBlogDesc(), localState.getBlogAuthorName(),
|
||||
localState.getSessionId(), localState.getBlogAuthorName(),
|
||||
localState.getBlogPublicKey(), time,
|
||||
localState.getMessage());
|
||||
}
|
||||
@@ -251,14 +245,12 @@ class BlogSharingManagerImpl extends
|
||||
MessageId storageId, GroupId groupId,
|
||||
InviteeSessionState.State state, ContactId contactId,
|
||||
GroupId blogId, BdfDictionary d) throws FormatException {
|
||||
String blogTitle = d.getString(BLOG_TITLE);
|
||||
String blogDesc = d.getString(BLOG_DESC);
|
||||
String blogAuthorName = d.getString(BLOG_AUTHOR_NAME);
|
||||
byte[] blogPublicKey = d.getRaw(BLOG_PUBLIC_KEY);
|
||||
MessageId invitationId = new MessageId(d.getRaw(INVITATION_ID));
|
||||
return new BlogInviteeSessionState(sessionId, storageId,
|
||||
groupId, state, contactId, blogId, blogTitle, blogDesc,
|
||||
blogAuthorName, blogPublicKey, invitationId);
|
||||
groupId, state, contactId, blogId, blogAuthorName,
|
||||
blogPublicKey, invitationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -267,9 +259,9 @@ class BlogSharingManagerImpl extends
|
||||
InviteeSessionState.State state, ContactId contactId,
|
||||
Blog blog, MessageId invitationId) {
|
||||
return new BlogInviteeSessionState(sessionId, storageId,
|
||||
groupId, state, contactId, blog.getId(), blog.getName(),
|
||||
blog.getDescription(), blog.getAuthor().getName(),
|
||||
blog.getAuthor().getPublicKey(), invitationId);
|
||||
groupId, state, contactId, blog.getId(),
|
||||
blog.getAuthor().getName(), blog.getAuthor().getPublicKey(),
|
||||
invitationId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,8 +272,6 @@ class BlogSharingManagerImpl extends
|
||||
MessageId storageId, GroupId groupId,
|
||||
SharerSessionState.State state, ContactId contactId,
|
||||
GroupId blogId, BdfDictionary d) throws FormatException {
|
||||
String blogTitle = d.getString(BLOG_TITLE);
|
||||
String blogDesc = d.getString(BLOG_DESC);
|
||||
String blogAuthorName = d.getString(BLOG_AUTHOR_NAME);
|
||||
byte[] blogPublicKey = d.getRaw(BLOG_PUBLIC_KEY);
|
||||
MessageId responseId = null;
|
||||
@@ -289,8 +279,8 @@ class BlogSharingManagerImpl extends
|
||||
if (responseIdBytes != null)
|
||||
responseId = new MessageId(responseIdBytes);
|
||||
return new BlogSharerSessionState(sessionId, storageId,
|
||||
groupId, state, contactId, blogId, blogTitle, blogDesc,
|
||||
blogAuthorName, blogPublicKey, responseId);
|
||||
groupId, state, contactId, blogId, blogAuthorName,
|
||||
blogPublicKey, responseId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -299,9 +289,9 @@ class BlogSharingManagerImpl extends
|
||||
SharerSessionState.State state, ContactId contactId,
|
||||
Blog blog) {
|
||||
return new BlogSharerSessionState(sessionId, storageId,
|
||||
groupId, state, contactId, blog.getId(), blog.getName(),
|
||||
blog.getDescription(), blog.getAuthor().getName(),
|
||||
blog.getAuthor().getPublicKey(), null);
|
||||
groupId, state, contactId, blog.getId(),
|
||||
blog.getAuthor().getName(), blog.getAuthor().getPublicKey(),
|
||||
null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,7 +323,6 @@ class BlogSharingManagerImpl extends
|
||||
@Override
|
||||
public BlogInvitationResponseReceivedEvent build(
|
||||
BlogSharerSessionState localState, boolean accept, long time) {
|
||||
String title = localState.getBlogTitle();
|
||||
ContactId c = localState.getContactId();
|
||||
MessageId responseId = localState.getResponseId();
|
||||
if (responseId == null)
|
||||
@@ -343,7 +332,7 @@ class BlogSharingManagerImpl extends
|
||||
localState.getSessionId(), localState.getGroupId(),
|
||||
localState.getContactId(), accept, time, false,
|
||||
false, false, false);
|
||||
return new BlogInvitationResponseReceivedEvent(title, c, response);
|
||||
return new BlogInvitationResponseReceivedEvent(c, response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,7 @@ import org.briarproject.clients.BdfMessageValidator;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.briarproject.api.blogs.BlogConstants.BLOG_AUTHOR_NAME;
|
||||
import static org.briarproject.api.blogs.BlogConstants.BLOG_DESC;
|
||||
import static org.briarproject.api.blogs.BlogConstants.BLOG_PUBLIC_KEY;
|
||||
import static org.briarproject.api.blogs.BlogConstants.BLOG_TITLE;
|
||||
import static org.briarproject.api.blogs.BlogConstants.MAX_BLOG_DESC_LENGTH;
|
||||
import static org.briarproject.api.blogs.BlogConstants.MAX_BLOG_TITLE_LENGTH;
|
||||
import static org.briarproject.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
|
||||
import static org.briarproject.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
||||
import static org.briarproject.api.sharing.SharingConstants.INVITATION_MSG;
|
||||
@@ -52,30 +48,22 @@ class BlogSharingValidator extends BdfMessageValidator {
|
||||
checkLength(id, SessionId.LENGTH);
|
||||
|
||||
if (type == SHARE_MSG_TYPE_INVITATION) {
|
||||
checkSize(body, 5, 6);
|
||||
checkSize(body, 3, 4);
|
||||
|
||||
String name = body.getString(2);
|
||||
checkLength(name, 1, MAX_BLOG_TITLE_LENGTH);
|
||||
|
||||
String desc = body.getString(3);
|
||||
checkLength(desc, 0, MAX_BLOG_DESC_LENGTH);
|
||||
|
||||
BdfList author = body.getList(4);
|
||||
BdfList author = body.getList(2);
|
||||
checkSize(author, 2);
|
||||
|
||||
String authorName = author.getString(0);
|
||||
checkLength(name, 1, MAX_AUTHOR_NAME_LENGTH);
|
||||
checkLength(authorName, 1, MAX_AUTHOR_NAME_LENGTH);
|
||||
|
||||
byte[] publicKey = author.getRaw(1);
|
||||
checkLength(publicKey, 1, MAX_PUBLIC_KEY_LENGTH);
|
||||
|
||||
d.put(BLOG_TITLE, name);
|
||||
d.put(BLOG_DESC, desc);
|
||||
d.put(BLOG_AUTHOR_NAME, authorName);
|
||||
d.put(BLOG_PUBLIC_KEY, publicKey);
|
||||
|
||||
if (body.size() > 5) {
|
||||
String msg = body.getString(5);
|
||||
if (body.size() > 3) {
|
||||
String msg = body.getString(3);
|
||||
checkLength(msg, 0, MAX_INVITATION_MESSAGE_LENGTH);
|
||||
d.put(INVITATION_MSG, msg);
|
||||
}
|
||||
|
||||
@@ -3,10 +3,13 @@ package org.briarproject.sharing;
|
||||
import org.briarproject.api.clients.SessionId;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.data.BdfDictionary;
|
||||
import org.briarproject.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.concurrent.NotThreadSafe;
|
||||
|
||||
import static org.briarproject.api.sharing.SharingConstants.INVITATION_ID;
|
||||
import static org.briarproject.api.sharing.SharingConstants.IS_SHARER;
|
||||
import static org.briarproject.api.sharing.SharingConstants.SHARE_MSG_TYPE_ABORT;
|
||||
@@ -19,7 +22,8 @@ import static org.briarproject.sharing.InviteeSessionState.Action.LOCAL_LEAVE;
|
||||
import static org.briarproject.sharing.InviteeSessionState.Action.REMOTE_INVITATION;
|
||||
import static org.briarproject.sharing.InviteeSessionState.Action.REMOTE_LEAVE;
|
||||
|
||||
// This class is not thread-safe
|
||||
@NotThreadSafe
|
||||
@NotNullByDefault
|
||||
public abstract class InviteeSessionState extends SharingSessionState {
|
||||
|
||||
private State state;
|
||||
|
||||
@@ -3,10 +3,13 @@ package org.briarproject.sharing;
|
||||
import org.briarproject.api.clients.SessionId;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.data.BdfDictionary;
|
||||
import org.briarproject.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.annotation.concurrent.NotThreadSafe;
|
||||
|
||||
import static org.briarproject.api.sharing.SharingConstants.IS_SHARER;
|
||||
import static org.briarproject.api.sharing.SharingConstants.RESPONSE_ID;
|
||||
import static org.briarproject.api.sharing.SharingConstants.SHARE_MSG_TYPE_ABORT;
|
||||
@@ -20,7 +23,8 @@ import static org.briarproject.sharing.SharerSessionState.Action.REMOTE_ACCEPT;
|
||||
import static org.briarproject.sharing.SharerSessionState.Action.REMOTE_DECLINE;
|
||||
import static org.briarproject.sharing.SharerSessionState.Action.REMOTE_LEAVE;
|
||||
|
||||
// This class is not thread-safe
|
||||
@NotThreadSafe
|
||||
@NotNullByDefault
|
||||
public abstract class SharerSessionState extends SharingSessionState {
|
||||
|
||||
private State state;
|
||||
@@ -58,6 +62,7 @@ public abstract class SharerSessionState extends SharingSessionState {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getMessage() {
|
||||
return this.msg;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,6 @@ import static org.briarproject.TestUtils.getRandomId;
|
||||
import static org.briarproject.api.blogs.BlogConstants.KEY_AUTHOR;
|
||||
import static org.briarproject.api.blogs.BlogConstants.KEY_AUTHOR_ID;
|
||||
import static org.briarproject.api.blogs.BlogConstants.KEY_AUTHOR_NAME;
|
||||
import static org.briarproject.api.blogs.BlogConstants.KEY_DESCRIPTION;
|
||||
import static org.briarproject.api.blogs.BlogConstants.KEY_PUBLIC_KEY;
|
||||
import static org.briarproject.api.blogs.BlogConstants.KEY_READ;
|
||||
import static org.briarproject.api.blogs.BlogConstants.KEY_TIMESTAMP;
|
||||
@@ -63,8 +62,6 @@ public class BlogManagerImplTest extends BriarTestCase {
|
||||
private final IdentityManager identityManager =
|
||||
context.mock(IdentityManager.class);
|
||||
private final ClientHelper clientHelper = context.mock(ClientHelper.class);
|
||||
private final MetadataParser metadataParser =
|
||||
context.mock(MetadataParser.class);
|
||||
private final ContactManager contactManager =
|
||||
context.mock(ContactManager.class);
|
||||
private final BlogFactory blogFactory = context.mock(BlogFactory.class);
|
||||
@@ -78,11 +75,12 @@ public class BlogManagerImplTest extends BriarTestCase {
|
||||
BlogPostFactory blogPostFactory;
|
||||
|
||||
public BlogManagerImplTest() {
|
||||
MetadataParser metadataParser = context.mock(MetadataParser.class);
|
||||
blogManager = new BlogManagerImpl(db, identityManager, clientHelper,
|
||||
metadataParser, contactManager, blogFactory, blogPostFactory);
|
||||
|
||||
blog1 = getBlog("Test Blog 1", "Test Description 1");
|
||||
blog2 = getBlog("Test Blog 2", "Test Description 2");
|
||||
blog1 = createBlog();
|
||||
blog2 = createBlog();
|
||||
messageId = new MessageId(getRandomId());
|
||||
message = new Message(messageId, blog1.getId(), 42, getRandomBytes(42));
|
||||
}
|
||||
@@ -95,8 +93,7 @@ public class BlogManagerImplTest extends BriarTestCase {
|
||||
@Test
|
||||
public void testCreateLocalState() throws DbException {
|
||||
final Transaction txn = new Transaction(null, false);
|
||||
final Collection<LocalAuthor> localAuthors =
|
||||
Collections.singletonList((LocalAuthor) blog1.getAuthor());
|
||||
final LocalAuthor localAuthor = (LocalAuthor) blog1.getAuthor();
|
||||
|
||||
final ContactId contactId = new ContactId(0);
|
||||
final Collection<ContactId> contactIds =
|
||||
@@ -107,9 +104,9 @@ public class BlogManagerImplTest extends BriarTestCase {
|
||||
final Collection<Contact> contacts = Collections.singletonList(contact);
|
||||
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(db).getLocalAuthors(txn);
|
||||
will(returnValue(localAuthors));
|
||||
oneOf(blogFactory).createPersonalBlog(blog1.getAuthor());
|
||||
oneOf(identityManager).getLocalAuthor(txn);
|
||||
will(returnValue(localAuthor));
|
||||
oneOf(blogFactory).createBlog(blog1.getAuthor());
|
||||
will(returnValue(blog1));
|
||||
oneOf(db).containsGroup(txn, blog1.getId());
|
||||
will(returnValue(false));
|
||||
@@ -119,7 +116,7 @@ public class BlogManagerImplTest extends BriarTestCase {
|
||||
oneOf(db).setVisibleToContact(txn, contactId, blog1.getId(), true);
|
||||
oneOf(db).getContacts(txn);
|
||||
will(returnValue(contacts));
|
||||
oneOf(blogFactory).createPersonalBlog(blog2.getAuthor());
|
||||
oneOf(blogFactory).createBlog(blog2.getAuthor());
|
||||
will(returnValue(blog2));
|
||||
oneOf(db).containsGroup(txn, blog2.getId());
|
||||
will(returnValue(false));
|
||||
@@ -127,7 +124,7 @@ public class BlogManagerImplTest extends BriarTestCase {
|
||||
oneOf(db).setVisibleToContact(txn, contactId, blog2.getId(), true);
|
||||
oneOf(db).getLocalAuthor(txn, blog1.getAuthor().getId());
|
||||
will(returnValue(blog1.getAuthor()));
|
||||
oneOf(blogFactory).createPersonalBlog(blog1.getAuthor());
|
||||
oneOf(blogFactory).createBlog(blog1.getAuthor());
|
||||
will(returnValue(blog1));
|
||||
oneOf(db).setVisibleToContact(txn, contactId, blog1.getId(), true);
|
||||
}});
|
||||
@@ -145,7 +142,7 @@ public class BlogManagerImplTest extends BriarTestCase {
|
||||
blog1.getAuthor().getId(), true, true);
|
||||
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(blogFactory).createPersonalBlog(blog2.getAuthor());
|
||||
oneOf(blogFactory).createBlog(blog2.getAuthor());
|
||||
will(returnValue(blog2));
|
||||
oneOf(db).removeGroup(txn, blog2.getGroup());
|
||||
}});
|
||||
@@ -163,7 +160,7 @@ public class BlogManagerImplTest extends BriarTestCase {
|
||||
a.getPublicKey(), 0);
|
||||
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(blogFactory).createPersonalBlog(localAuthor);
|
||||
oneOf(blogFactory).createBlog(localAuthor);
|
||||
will(returnValue(blog1));
|
||||
oneOf(db).addGroup(txn, blog1.getGroup());
|
||||
}});
|
||||
@@ -181,7 +178,7 @@ public class BlogManagerImplTest extends BriarTestCase {
|
||||
a.getPublicKey(), 0);
|
||||
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(blogFactory).createPersonalBlog(localAuthor);
|
||||
oneOf(blogFactory).createBlog(localAuthor);
|
||||
will(returnValue(blog1));
|
||||
oneOf(db).removeGroup(txn, blog1.getGroup());
|
||||
}});
|
||||
@@ -226,35 +223,6 @@ public class BlogManagerImplTest extends BriarTestCase {
|
||||
assertEquals(blog1.getAuthor(), h.getAuthor());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddBlog() throws DbException, FormatException {
|
||||
final Transaction txn = new Transaction(null, false);
|
||||
Author a = blog1.getAuthor();
|
||||
final LocalAuthor localAuthor =
|
||||
new LocalAuthor(a.getId(), a.getName(), a.getPublicKey(),
|
||||
a.getPublicKey(), 0);
|
||||
final BdfDictionary meta = BdfDictionary.of(
|
||||
new BdfEntry(KEY_DESCRIPTION, blog1.getDescription())
|
||||
);
|
||||
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(blogFactory)
|
||||
.createBlog(blog1.getName(), blog1.getDescription(),
|
||||
blog1.getAuthor());
|
||||
will(returnValue(blog1));
|
||||
oneOf(db).startTransaction(false);
|
||||
will(returnValue(txn));
|
||||
oneOf(db).addGroup(txn, blog1.getGroup());
|
||||
oneOf(clientHelper).mergeGroupMetadata(txn, blog1.getId(), meta);
|
||||
oneOf(db).endTransaction(txn);
|
||||
}});
|
||||
|
||||
blogManager
|
||||
.addBlog(localAuthor, blog1.getName(), blog1.getDescription());
|
||||
context.assertIsSatisfied();
|
||||
assertTrue(txn.isComplete());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveBlog() throws Exception {
|
||||
final Transaction txn = new Transaction(null, false);
|
||||
@@ -369,15 +337,12 @@ public class BlogManagerImplTest extends BriarTestCase {
|
||||
will(returnValue(txn));
|
||||
oneOf(db).getGroup(txn, blog.getId());
|
||||
will(returnValue(blog.getGroup()));
|
||||
oneOf(clientHelper)
|
||||
.getGroupMetadataAsDictionary(txn, blog.getId());
|
||||
will(returnValue(new BdfDictionary()));
|
||||
oneOf(blogFactory).parseBlog(blog.getGroup(), "");
|
||||
oneOf(blogFactory).parseBlog(blog.getGroup());
|
||||
will(returnValue(blog));
|
||||
}});
|
||||
}
|
||||
|
||||
private Blog getBlog(String name, String desc) {
|
||||
private Blog createBlog() {
|
||||
final GroupId groupId = new GroupId(getRandomId());
|
||||
final Group group = new Group(groupId, CLIENT_ID, getRandomBytes(42));
|
||||
final AuthorId authorId = new AuthorId(getRandomId());
|
||||
@@ -387,7 +352,7 @@ public class BlogManagerImplTest extends BriarTestCase {
|
||||
final LocalAuthor localAuthor =
|
||||
new LocalAuthor(authorId, "Author", publicKey, privateKey,
|
||||
created);
|
||||
return new Blog(group, name, desc, localAuthor);
|
||||
return new Blog(group, localAuthor);
|
||||
}
|
||||
|
||||
private BdfDictionary authorToBdfDictionary(Author a) {
|
||||
|
||||
@@ -50,23 +50,19 @@ public class BlogPostValidatorTest extends BriarTestCase {
|
||||
|
||||
private final Mockery context = new Mockery();
|
||||
private final Blog blog;
|
||||
private final Author author;
|
||||
private final BdfDictionary authorDict;
|
||||
private final ClientId clientId;
|
||||
private final byte[] descriptor;
|
||||
private final Group group;
|
||||
private final Message message;
|
||||
private final BlogPostValidator validator;
|
||||
private final CryptoComponent cryptoComponent =
|
||||
context.mock(CryptoComponent.class);
|
||||
private final GroupFactory groupFactory = context.mock(GroupFactory.class);
|
||||
private final MessageFactory messageFactory =
|
||||
context.mock(MessageFactory.class);
|
||||
private final BlogFactory blogFactory = context.mock(BlogFactory.class);
|
||||
private final ClientHelper clientHelper = context.mock(ClientHelper.class);
|
||||
private final Clock clock = new SystemClock();
|
||||
private final Author author;
|
||||
private final String body = TestUtils.getRandomString(42);
|
||||
private final String contentType = "text/plain";
|
||||
|
||||
public BlogPostValidatorTest() {
|
||||
GroupId groupId = new GroupId(TestUtils.getRandomId());
|
||||
@@ -82,7 +78,7 @@ public class BlogPostValidatorTest extends BriarTestCase {
|
||||
new BdfEntry(KEY_AUTHOR_NAME, author.getName()),
|
||||
new BdfEntry(KEY_PUBLIC_KEY, author.getPublicKey())
|
||||
);
|
||||
blog = new Blog(group, "Test Blog", "", author);
|
||||
blog = new Blog(group, author);
|
||||
|
||||
MessageId messageId = new MessageId(TestUtils.getRandomId());
|
||||
long timestamp = System.currentTimeMillis();
|
||||
@@ -90,8 +86,10 @@ public class BlogPostValidatorTest extends BriarTestCase {
|
||||
message = new Message(messageId, group.getId(), timestamp, raw);
|
||||
|
||||
MetadataEncoder metadataEncoder = context.mock(MetadataEncoder.class);
|
||||
validator = new BlogPostValidator(groupFactory, messageFactory,
|
||||
blogFactory, clientHelper, metadataEncoder, clock);
|
||||
Clock clock = new SystemClock();
|
||||
validator =
|
||||
new BlogPostValidator(groupFactory, messageFactory, blogFactory,
|
||||
clientHelper, metadataEncoder, clock);
|
||||
context.assertIsSatisfied();
|
||||
}
|
||||
|
||||
@@ -115,7 +113,7 @@ public class BlogPostValidatorTest extends BriarTestCase {
|
||||
@Test(expected = FormatException.class)
|
||||
public void testValidateBlogPostWithoutAttachments()
|
||||
throws IOException, GeneralSecurityException {
|
||||
BdfList content = BdfList.of(null, contentType, null, body);
|
||||
BdfList content = BdfList.of(null, null, body);
|
||||
BdfList m = BdfList.of(POST.getInt(), content, null);
|
||||
|
||||
validator.validateMessage(message, group, m).getDictionary();
|
||||
@@ -124,7 +122,7 @@ public class BlogPostValidatorTest extends BriarTestCase {
|
||||
@Test(expected = FormatException.class)
|
||||
public void testValidateBlogPostWithoutSignature()
|
||||
throws IOException, GeneralSecurityException {
|
||||
BdfList content = BdfList.of(null, contentType, null, body, null);
|
||||
BdfList content = BdfList.of(null, null, body, null);
|
||||
BdfList m = BdfList.of(POST.getInt(), content, null);
|
||||
|
||||
validator.validateMessage(message, group, m).getDictionary();
|
||||
@@ -261,7 +259,7 @@ public class BlogPostValidatorTest extends BriarTestCase {
|
||||
private void expectCrypto(final BdfList signed, final byte[] sig)
|
||||
throws IOException, GeneralSecurityException {
|
||||
context.checking(new Expectations() {{
|
||||
oneOf(blogFactory).parseBlog(group, "");
|
||||
oneOf(blogFactory).parseBlog(group);
|
||||
will(returnValue(blog));
|
||||
oneOf(clientHelper)
|
||||
.verifySignature(sig, author.getPublicKey(), signed);
|
||||
|
||||
Reference in New Issue
Block a user