Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
briar
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
680
Issues
680
List
Boards
Labels
Service Desk
Milestones
Merge Requests
11
Merge Requests
11
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
briar
briar
Commits
64aa121c
Verified
Commit
64aa121c
authored
Apr 26, 2019
by
akwizgran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reuse UnsupportedVersionException for handshake links.
parent
cc3486df
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
6 deletions
+24
-6
bramble-api/src/main/java/org/briarproject/bramble/api/contact/ContactManager.java
.../org/briarproject/bramble/api/contact/ContactManager.java
+12
-5
bramble-core/src/main/java/org/briarproject/bramble/contact/PendingContactFactory.java
...g/briarproject/bramble/contact/PendingContactFactory.java
+8
-0
bramble-core/src/main/java/org/briarproject/bramble/contact/PendingContactFactoryImpl.java
...iarproject/bramble/contact/PendingContactFactoryImpl.java
+4
-1
No files found.
bramble-api/src/main/java/org/briarproject/bramble/api/contact/ContactManager.java
View file @
64aa121c
package
org.briarproject.bramble.api.contact
;
import
org.briarproject.bramble.api.FormatException
;
import
org.briarproject.bramble.api.UnsupportedVersionException
;
import
org.briarproject.bramble.api.crypto.SecretKey
;
import
org.briarproject.bramble.api.db.DbException
;
import
org.briarproject.bramble.api.db.NoSuchContactException
;
import
org.briarproject.bramble.api.db.Transaction
;
import
org.briarproject.bramble.api.identity.Author
;
import
org.briarproject.bramble.api.identity.AuthorId
;
...
...
@@ -65,10 +67,15 @@ public interface ContactManager {
String
getHandshakeLink
()
throws
DbException
;
/**
* Adds a new pending contact identified by the given handshake link.
* Creates a {@link PendingContact} from the given handshake link and
* alias, adds it to the database and returns it.
*
* @param link The handshake link received from the contact we want to add.
* @param alias The alias the user has given this contact.
* @param link The handshake link received from the contact we want to add
* @param alias The alias the user has given this contact
* @return A PendingContact representing the contact to be added
* @throws UnsupportedVersionException If the link uses a format version
* that is not supported
* @throws FormatException If the link is invalid
*/
PendingContact
addPendingContact
(
String
link
,
String
alias
)
throws
DbException
,
FormatException
;
...
...
@@ -92,7 +99,7 @@ public interface ContactManager {
* Returns the contact with the given remoteAuthorId
* that was added by the LocalAuthor with the given localAuthorId
*
* @throws
org.briarproject.bramble.api.db.NoSuchContactException
* @throws
NoSuchContactException If the contact is not in the database
*/
Contact
getContact
(
AuthorId
remoteAuthorId
,
AuthorId
localAuthorId
)
throws
DbException
;
...
...
@@ -101,7 +108,7 @@ public interface ContactManager {
* Returns the contact with the given remoteAuthorId
* that was added by the LocalAuthor with the given localAuthorId
*
* @throws
org.briarproject.bramble.api.db.NoSuchContactException
* @throws
NoSuchContactException If the contact is not in the database
*/
Contact
getContact
(
Transaction
txn
,
AuthorId
remoteAuthorId
,
AuthorId
localAuthorId
)
throws
DbException
;
...
...
bramble-core/src/main/java/org/briarproject/bramble/contact/PendingContactFactory.java
View file @
64aa121c
package
org.briarproject.bramble.contact
;
import
org.briarproject.bramble.api.FormatException
;
import
org.briarproject.bramble.api.UnsupportedVersionException
;
import
org.briarproject.bramble.api.contact.PendingContact
;
interface
PendingContactFactory
{
/**
* Creates a {@link PendingContact} from the given handshake link and alias.
*
* @throws UnsupportedVersionException If the link uses a format version
* that is not supported
* @throws FormatException If the link is invalid
*/
PendingContact
createPendingContact
(
String
link
,
String
alias
)
throws
FormatException
;
}
bramble-core/src/main/java/org/briarproject/bramble/contact/PendingContactFactoryImpl.java
View file @
64aa121c
package
org.briarproject.bramble.contact
;
import
org.briarproject.bramble.api.FormatException
;
import
org.briarproject.bramble.api.UnsupportedVersionException
;
import
org.briarproject.bramble.api.contact.PendingContact
;
import
org.briarproject.bramble.api.contact.PendingContactId
;
import
org.briarproject.bramble.api.contact.PendingContactState
;
...
...
@@ -49,7 +50,9 @@ class PendingContactFactoryImpl implements PendingContactFactory {
if
(
link
.
startsWith
(
"briar://"
))
link
=
link
.
substring
(
8
);
byte
[]
base32
=
Base32
.
decode
(
link
,
false
);
if
(
base32
.
length
!=
RAW_LINK_BYTES
)
throw
new
AssertionError
();
if
(
base32
[
0
]
!=
FORMAT_VERSION
)
throw
new
FormatException
();
byte
version
=
base32
[
0
];
if
(
version
!=
FORMAT_VERSION
)
throw
new
UnsupportedVersionException
(
version
<
FORMAT_VERSION
);
byte
[]
publicKeyBytes
=
new
byte
[
base32
.
length
-
1
];
arraycopy
(
base32
,
1
,
publicKeyBytes
,
0
,
publicKeyBytes
.
length
);
try
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment