mirror of
https://github.com/etesync/android
synced 2025-01-23 22:21:23 +00:00
Fix many compilation warnings
Either deprecated usage or kotlin warnings
This commit is contained in:
parent
a7f0144fc8
commit
e39e882c0a
@ -72,8 +72,8 @@ class NotificationHelper(internal val context: Context, internal val notificatio
|
|||||||
}
|
}
|
||||||
|
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun notify(title: String, content: String, bigText: String?, intent: Intent, icon: Int = -1) {
|
fun notify(title: String, content: String, bigText: String?, intent: Intent, _icon: Int = -1) {
|
||||||
var icon = icon
|
var icon = _icon
|
||||||
createNotificationChannel()
|
createNotificationChannel()
|
||||||
val builder = NotificationCompat.Builder(context)
|
val builder = NotificationCompat.Builder(context)
|
||||||
val category = if (throwable == null)
|
val category = if (throwable == null)
|
||||||
|
@ -3,7 +3,6 @@ package com.etesync.syncadapter.journalmanager
|
|||||||
import com.etesync.syncadapter.App
|
import com.etesync.syncadapter.App
|
||||||
import com.etesync.syncadapter.GsonHelper
|
import com.etesync.syncadapter.GsonHelper
|
||||||
import okhttp3.*
|
import okhttp3.*
|
||||||
import org.apache.commons.codec.Charsets
|
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.net.HttpURLConnection
|
import java.net.HttpURLConnection
|
||||||
@ -51,11 +50,11 @@ abstract class BaseManager {
|
|||||||
var uid: String? = null
|
var uid: String? = null
|
||||||
|
|
||||||
fun getContent(crypto: Crypto.CryptoManager): String {
|
fun getContent(crypto: Crypto.CryptoManager): String {
|
||||||
return String(crypto.decrypt(content!!)!!, Charsets.UTF_8)
|
return String(crypto.decrypt(content!!)!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setContent(crypto: Crypto.CryptoManager, content: String) {
|
fun setContent(crypto: Crypto.CryptoManager, content: String) {
|
||||||
this.content = crypto.encrypt(content.toByteArray(Charsets.UTF_8))
|
this.content = crypto.encrypt(content.toByteArray())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun calculateHmac(crypto: Crypto.CryptoManager, uuid: String?): ByteArray {
|
fun calculateHmac(crypto: Crypto.CryptoManager, uuid: String?): ByteArray {
|
||||||
@ -63,7 +62,7 @@ abstract class BaseManager {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
hashContent.write(uuid.toByteArray(Charsets.UTF_8))
|
hashContent.write(uuid.toByteArray())
|
||||||
}
|
}
|
||||||
|
|
||||||
hashContent.write(content!!)
|
hashContent.write(content!!)
|
||||||
|
@ -37,7 +37,7 @@ object Crypto {
|
|||||||
fun deriveKey(salt: String, password: String): String {
|
fun deriveKey(salt: String, password: String): String {
|
||||||
val keySize = 190
|
val keySize = 190
|
||||||
|
|
||||||
return Base64.encodeToString(SCrypt.generate(password.toByteArray(Charsets.UTF_8), salt.toByteArray(Charsets.UTF_8), 16384, 8, 1, keySize), Base64.NO_WRAP)
|
return Base64.encodeToString(SCrypt.generate(password.toByteArray(), salt.toByteArray(), 16384, 8, 1, keySize), Base64.NO_WRAP)
|
||||||
}
|
}
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@ -130,8 +130,8 @@ object Crypto {
|
|||||||
get() = SecureRandom()
|
get() = SecureRandom()
|
||||||
|
|
||||||
private fun setDerivedKey(derivedKey: ByteArray?) {
|
private fun setDerivedKey(derivedKey: ByteArray?) {
|
||||||
cipherKey = hmac256("aes".toByteArray(Charsets.UTF_8), derivedKey)
|
cipherKey = hmac256("aes".toByteArray(), derivedKey)
|
||||||
hmacKey = hmac256("hmac".toByteArray(Charsets.UTF_8), derivedKey)
|
hmacKey = hmac256("hmac".toByteArray(), derivedKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(version: Int, keyPair: AsymmetricKeyPair, encryptedKey: ByteArray) {
|
constructor(version: Int, keyPair: AsymmetricKeyPair, encryptedKey: ByteArray) {
|
||||||
@ -151,7 +151,7 @@ object Crypto {
|
|||||||
} else if (version == 1) {
|
} else if (version == 1) {
|
||||||
derivedKey = Base64.decode(keyBase64, Base64.NO_WRAP)
|
derivedKey = Base64.decode(keyBase64, Base64.NO_WRAP)
|
||||||
} else {
|
} else {
|
||||||
derivedKey = hmac256(salt.toByteArray(Charsets.UTF_8), Base64.decode(keyBase64, Base64.NO_WRAP))
|
derivedKey = hmac256(salt.toByteArray(), Base64.decode(keyBase64, Base64.NO_WRAP))
|
||||||
}
|
}
|
||||||
|
|
||||||
this.version = version.toByte()
|
this.version = version.toByte()
|
||||||
@ -246,7 +246,7 @@ object Crypto {
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal fun sha256(base: String): String {
|
internal fun sha256(base: String): String {
|
||||||
return toHex(sha256(base.toByteArray(Charsets.UTF_8)))
|
return toHex(sha256(base.toByteArray()))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sha256(base: ByteArray): ByteArray {
|
private fun sha256(base: ByteArray): ByteArray {
|
||||||
|
@ -102,7 +102,7 @@ class LocalAddressBook(
|
|||||||
// HELPERS
|
// HELPERS
|
||||||
|
|
||||||
fun accountName(mainAccount: Account, info: CollectionInfo): String {
|
fun accountName(mainAccount: Account, info: CollectionInfo): String {
|
||||||
val displayName = if (info.displayName != null) info.displayName else info.uid
|
val displayName = info.displayName ?: info.uid!!
|
||||||
val sb = StringBuilder(displayName)
|
val sb = StringBuilder(displayName)
|
||||||
sb.append(" (")
|
sb.append(" (")
|
||||||
.append(mainAccount.name)
|
.append(mainAccount.name)
|
||||||
|
@ -121,7 +121,7 @@ constructor(context: Context, account: Account, settings: AccountSettings, extra
|
|||||||
@Throws(CalendarStorageException::class, ContactsStorageException::class, IOException::class)
|
@Throws(CalendarStorageException::class, ContactsStorageException::class, IOException::class)
|
||||||
private fun createInviteAttendeesNotification() {
|
private fun createInviteAttendeesNotification() {
|
||||||
for (local in localDirty) {
|
for (local in localDirty) {
|
||||||
val event = (local as LocalEvent).event
|
val event = local.event
|
||||||
|
|
||||||
if (event?.attendees?.isEmpty()!!) {
|
if (event?.attendees?.isEmpty()!!) {
|
||||||
return
|
return
|
||||||
@ -144,8 +144,8 @@ constructor(context: Context, account: Account, settings: AccountSettings, extra
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Throws(IOException::class, ContactsStorageException::class, CalendarStorageException::class)
|
@Throws(IOException::class, ContactsStorageException::class, CalendarStorageException::class)
|
||||||
private fun processEvent(newData: Event, localEvent: LocalEvent?): LocalEvent {
|
private fun processEvent(newData: Event, _localEvent: LocalEvent?): LocalEvent {
|
||||||
var localEvent = localEvent
|
var localEvent = _localEvent
|
||||||
// delete local event, if it exists
|
// delete local event, if it exists
|
||||||
if (localEvent != null) {
|
if (localEvent != null) {
|
||||||
App.log.info("Updating " + newData.uid + " in local calendar")
|
App.log.info("Updating " + newData.uid + " in local calendar")
|
||||||
|
@ -52,7 +52,7 @@ import java.io.StringReader
|
|||||||
* Synchronization manager for CardDAV collections; handles contacts and groups.
|
* Synchronization manager for CardDAV collections; handles contacts and groups.
|
||||||
*/
|
*/
|
||||||
class ContactsSyncManager @Throws(Exceptions.IntegrityException::class, Exceptions.GenericCryptoException::class, ContactsStorageException::class)
|
class ContactsSyncManager @Throws(Exceptions.IntegrityException::class, Exceptions.GenericCryptoException::class, ContactsStorageException::class)
|
||||||
constructor(context: Context, account: Account, settings: AccountSettings, extras: Bundle, authority: String, private val provider: ContentProviderClient, result: SyncResult, localAddressBook: LocalAddressBook, private val remote: HttpUrl) : SyncManager<LocalAddress>(context, account, settings, extras, authority, result, localAddressBook.url!!, CollectionInfo.Type.ADDRESS_BOOK, localAddressBook.mainAccount.name) {
|
constructor(context: Context, account: Account, settings: AccountSettings, extras: Bundle, authority: String, private val provider: ContentProviderClient, result: SyncResult, localAddressBook: LocalAddressBook, private val remote: HttpUrl) : SyncManager<LocalAddress>(context, account, settings, extras, authority, result, localAddressBook.url, CollectionInfo.Type.ADDRESS_BOOK, localAddressBook.mainAccount.name) {
|
||||||
|
|
||||||
protected override val syncErrorTitle: String
|
protected override val syncErrorTitle: String
|
||||||
get() = context.getString(R.string.sync_error_contacts, account.name)
|
get() = context.getString(R.string.sync_error_contacts, account.name)
|
||||||
@ -171,8 +171,8 @@ constructor(context: Context, account: Account, settings: AccountSettings, extra
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Throws(IOException::class, ContactsStorageException::class)
|
@Throws(IOException::class, ContactsStorageException::class)
|
||||||
private fun processContact(newData: Contact, local: LocalAddress?): LocalAddress {
|
private fun processContact(newData: Contact, _local: LocalAddress?): LocalAddress {
|
||||||
var local = local
|
var local = _local
|
||||||
val uuid = newData.uid
|
val uuid = newData.uid
|
||||||
// update local contact, if it exists
|
// update local contact, if it exists
|
||||||
if (local != null) {
|
if (local != null) {
|
||||||
@ -181,14 +181,14 @@ constructor(context: Context, account: Account, settings: AccountSettings, extra
|
|||||||
if (local is LocalGroup && newData.group) {
|
if (local is LocalGroup && newData.group) {
|
||||||
// update group
|
// update group
|
||||||
val group: LocalGroup = local
|
val group: LocalGroup = local
|
||||||
group!!.eTag = uuid
|
group.eTag = uuid
|
||||||
group.update(newData)
|
group.update(newData)
|
||||||
syncResult.stats.numUpdates++
|
syncResult.stats.numUpdates++
|
||||||
|
|
||||||
} else if (local is LocalContact && !newData.group) {
|
} else if (local is LocalContact && !newData.group) {
|
||||||
// update contact
|
// update contact
|
||||||
val contact: LocalContact = local
|
val contact: LocalContact = local
|
||||||
contact!!.eTag = uuid
|
contact.eTag = uuid
|
||||||
contact.update(newData)
|
contact.update(newData)
|
||||||
syncResult.stats.numUpdates++
|
syncResult.stats.numUpdates++
|
||||||
|
|
||||||
|
@ -99,8 +99,8 @@ class TasksSyncManager(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun processTask(newData: Task, localTask: LocalTask?): LocalTask {
|
private fun processTask(newData: Task, _localTask: LocalTask?): LocalTask {
|
||||||
var localTask = localTask
|
var localTask = _localTask
|
||||||
// delete local Task, if it exists
|
// delete local Task, if it exists
|
||||||
if (localTask != null) {
|
if (localTask != null) {
|
||||||
App.log.info("Updating " + newData.uid + " in local calendar")
|
App.log.info("Updating " + newData.uid + " in local calendar")
|
||||||
|
@ -105,7 +105,7 @@ class AboutActivity : BaseActivity() {
|
|||||||
|
|
||||||
override fun onLoadFinished(loader: Loader<Spanned>, license: Spanned) {
|
override fun onLoadFinished(loader: Loader<Spanned>, license: Spanned) {
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
val tv = view!!.findViewById<View>(R.id.license_text) as TextView
|
val tv = view!!.findViewById<View>(R.id.license_text) as TextView?
|
||||||
if (tv != null) {
|
if (tv != null) {
|
||||||
tv.autoLinkMask = Linkify.EMAIL_ADDRESSES or Linkify.WEB_URLS
|
tv.autoLinkMask = Linkify.EMAIL_ADDRESSES or Linkify.WEB_URLS
|
||||||
tv.text = license
|
tv.text = license
|
||||||
|
@ -50,20 +50,19 @@ class AccountActivity : BaseActivity(), Toolbar.OnMenuItemClickListener, PopupMe
|
|||||||
internal var listCardDAV: ListView? = null
|
internal var listCardDAV: ListView? = null
|
||||||
internal var listTaskDAV: ListView? = null
|
internal var listTaskDAV: ListView? = null
|
||||||
|
|
||||||
private val onItemClickListener = AdapterView.OnItemClickListener { parent, view, position, id ->
|
private val onItemClickListener = AdapterView.OnItemClickListener { parent, view, position, _ ->
|
||||||
val list = parent as ListView
|
val list = parent as ListView
|
||||||
val adapter = list.adapter as ArrayAdapter<*>
|
val adapter = list.adapter as ArrayAdapter<*>
|
||||||
val journalEntity = adapter.getItem(position) as JournalEntity
|
val journalEntity = adapter.getItem(position) as JournalEntity
|
||||||
val info = journalEntity.getInfo()
|
val info = journalEntity.getInfo()
|
||||||
|
|
||||||
startActivity(ViewCollectionActivity.newIntent(this@AccountActivity, account!!, info))
|
startActivity(ViewCollectionActivity.newIntent(this@AccountActivity, account, info))
|
||||||
}
|
}
|
||||||
|
|
||||||
private val formattedFingerprint: String?
|
private val formattedFingerprint: String?
|
||||||
get() {
|
get() {
|
||||||
var settings: AccountSettings? = null
|
|
||||||
try {
|
try {
|
||||||
settings = AccountSettings(this, account!!)
|
val settings = AccountSettings(this, account)
|
||||||
return Crypto.AsymmetricCryptoManager.getPrettyKeyFingerprint(settings.keyPair!!.publicKey)
|
return Crypto.AsymmetricCryptoManager.getPrettyKeyFingerprint(settings.keyPair!!.publicKey)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
@ -76,7 +75,7 @@ class AccountActivity : BaseActivity(), Toolbar.OnMenuItemClickListener, PopupMe
|
|||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
account = intent.getParcelableExtra(EXTRA_ACCOUNT)
|
account = intent.getParcelableExtra(EXTRA_ACCOUNT)
|
||||||
title = account!!.name
|
title = account.name
|
||||||
|
|
||||||
setContentView(R.layout.activity_account)
|
setContentView(R.layout.activity_account)
|
||||||
|
|
||||||
@ -113,8 +112,8 @@ class AccountActivity : BaseActivity(), Toolbar.OnMenuItemClickListener, PopupMe
|
|||||||
HintManager.setHintSeen(this, HINT_VIEW_COLLECTION, true)
|
HintManager.setHintSeen(this, HINT_VIEW_COLLECTION, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!SetupUserInfoFragment.hasUserInfo(this, account!!)) {
|
if (!SetupUserInfoFragment.hasUserInfo(this, account)) {
|
||||||
SetupUserInfoFragment.newInstance(account!!).show(supportFragmentManager, null)
|
SetupUserInfoFragment.newInstance(account).show(supportFragmentManager, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +135,7 @@ class AccountActivity : BaseActivity(), Toolbar.OnMenuItemClickListener, PopupMe
|
|||||||
.setTitle(R.string.account_delete_confirmation_title)
|
.setTitle(R.string.account_delete_confirmation_title)
|
||||||
.setMessage(R.string.account_delete_confirmation_text)
|
.setMessage(R.string.account_delete_confirmation_text)
|
||||||
.setNegativeButton(android.R.string.no, null)
|
.setNegativeButton(android.R.string.no, null)
|
||||||
.setPositiveButton(android.R.string.yes) { dialog, which -> deleteAccount() }
|
.setPositiveButton(android.R.string.yes) { _, _ -> deleteAccount() }
|
||||||
.show()
|
.show()
|
||||||
R.id.show_fingerprint -> {
|
R.id.show_fingerprint -> {
|
||||||
val view = layoutInflater.inflate(R.layout.fingerprint_alertdialog, null)
|
val view = layoutInflater.inflate(R.layout.fingerprint_alertdialog, null)
|
||||||
@ -146,7 +145,7 @@ class AccountActivity : BaseActivity(), Toolbar.OnMenuItemClickListener, PopupMe
|
|||||||
.setIcon(R.drawable.ic_fingerprint_dark)
|
.setIcon(R.drawable.ic_fingerprint_dark)
|
||||||
.setTitle(R.string.show_fingperprint_title)
|
.setTitle(R.string.show_fingperprint_title)
|
||||||
.setView(view)
|
.setView(view)
|
||||||
.setPositiveButton(android.R.string.yes) { dialog, which -> }.create()
|
.setPositiveButton(android.R.string.yes) { _, _ -> }.create()
|
||||||
dialog.show()
|
dialog.show()
|
||||||
}
|
}
|
||||||
else -> return super.onOptionsItemSelected(item)
|
else -> return super.onOptionsItemSelected(item)
|
||||||
@ -160,17 +159,17 @@ class AccountActivity : BaseActivity(), Toolbar.OnMenuItemClickListener, PopupMe
|
|||||||
R.id.create_calendar -> {
|
R.id.create_calendar -> {
|
||||||
info = CollectionInfo()
|
info = CollectionInfo()
|
||||||
info.type = CollectionInfo.Type.CALENDAR
|
info.type = CollectionInfo.Type.CALENDAR
|
||||||
startActivity(CreateCollectionActivity.newIntent(this@AccountActivity, account!!, info))
|
startActivity(CreateCollectionActivity.newIntent(this@AccountActivity, account, info))
|
||||||
}
|
}
|
||||||
R.id.create_tasklist -> {
|
R.id.create_tasklist -> {
|
||||||
info = CollectionInfo()
|
info = CollectionInfo()
|
||||||
info.type = CollectionInfo.Type.TASKS
|
info.type = CollectionInfo.Type.TASKS
|
||||||
startActivity(CreateCollectionActivity.newIntent(this@AccountActivity, account!!, info))
|
startActivity(CreateCollectionActivity.newIntent(this@AccountActivity, account, info))
|
||||||
}
|
}
|
||||||
R.id.create_addressbook -> {
|
R.id.create_addressbook -> {
|
||||||
info = CollectionInfo()
|
info = CollectionInfo()
|
||||||
info.type = CollectionInfo.Type.ADDRESS_BOOK
|
info.type = CollectionInfo.Type.ADDRESS_BOOK
|
||||||
startActivity(CreateCollectionActivity.newIntent(this@AccountActivity, account!!, info))
|
startActivity(CreateCollectionActivity.newIntent(this@AccountActivity, account, info))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
@ -192,7 +191,7 @@ class AccountActivity : BaseActivity(), Toolbar.OnMenuItemClickListener, PopupMe
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateLoader(id: Int, args: Bundle?): Loader<AccountInfo> {
|
override fun onCreateLoader(id: Int, args: Bundle?): Loader<AccountInfo> {
|
||||||
return AccountLoader(this, account!!)
|
return AccountLoader(this, account)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun refresh() {
|
override fun refresh() {
|
||||||
@ -211,7 +210,7 @@ class AccountActivity : BaseActivity(), Toolbar.OnMenuItemClickListener, PopupMe
|
|||||||
listCardDAV!!.isEnabled = !info.carddav!!.refreshing
|
listCardDAV!!.isEnabled = !info.carddav!!.refreshing
|
||||||
listCardDAV!!.setAlpha(if (info.carddav!!.refreshing) 0.5f else 1f)
|
listCardDAV!!.setAlpha(if (info.carddav!!.refreshing) 0.5f else 1f)
|
||||||
|
|
||||||
val adapter = CollectionListAdapter(this, account!!)
|
val adapter = CollectionListAdapter(this, account)
|
||||||
adapter.addAll(info.carddav!!.journals!!)
|
adapter.addAll(info.carddav!!.journals!!)
|
||||||
listCardDAV!!.adapter = adapter
|
listCardDAV!!.adapter = adapter
|
||||||
listCardDAV!!.onItemClickListener = onItemClickListener
|
listCardDAV!!.onItemClickListener = onItemClickListener
|
||||||
@ -227,7 +226,7 @@ class AccountActivity : BaseActivity(), Toolbar.OnMenuItemClickListener, PopupMe
|
|||||||
listCalDAV!!.isEnabled = !info.caldav!!.refreshing
|
listCalDAV!!.isEnabled = !info.caldav!!.refreshing
|
||||||
listCalDAV!!.setAlpha(if (info.caldav!!.refreshing) 0.5f else 1f)
|
listCalDAV!!.setAlpha(if (info.caldav!!.refreshing) 0.5f else 1f)
|
||||||
|
|
||||||
val adapter = CollectionListAdapter(this, account!!)
|
val adapter = CollectionListAdapter(this, account)
|
||||||
adapter.addAll(info.caldav!!.journals!!)
|
adapter.addAll(info.caldav!!.journals!!)
|
||||||
listCalDAV!!.adapter = adapter
|
listCalDAV!!.adapter = adapter
|
||||||
listCalDAV!!.onItemClickListener = onItemClickListener
|
listCalDAV!!.onItemClickListener = onItemClickListener
|
||||||
@ -243,7 +242,7 @@ class AccountActivity : BaseActivity(), Toolbar.OnMenuItemClickListener, PopupMe
|
|||||||
listTaskDAV!!.isEnabled = !info.taskdav!!.refreshing
|
listTaskDAV!!.isEnabled = !info.taskdav!!.refreshing
|
||||||
listTaskDAV!!.setAlpha(if (info.taskdav!!.refreshing) 0.5f else 1f)
|
listTaskDAV!!.setAlpha(if (info.taskdav!!.refreshing) 0.5f else 1f)
|
||||||
|
|
||||||
val adapter = CollectionListAdapter(this, account!!)
|
val adapter = CollectionListAdapter(this, account)
|
||||||
adapter.addAll(info.taskdav!!.journals!!)
|
adapter.addAll(info.taskdav!!.journals!!)
|
||||||
listTaskDAV!!.adapter = adapter
|
listTaskDAV!!.adapter = adapter
|
||||||
listTaskDAV!!.onItemClickListener = onItemClickListener
|
listTaskDAV!!.onItemClickListener = onItemClickListener
|
||||||
|
@ -54,7 +54,7 @@ class RemoveMemberFragment : DialogFragment() {
|
|||||||
val journalsManager = JournalManager(httpClient!!, remote!!)
|
val journalsManager = JournalManager(httpClient!!, remote!!)
|
||||||
val journal = JournalManager.Journal.fakeWithUid(info!!.uid!!)
|
val journal = JournalManager.Journal.fakeWithUid(info!!.uid!!)
|
||||||
|
|
||||||
val member = JournalManager.Member(memberEmail!!, "placeholder".toByteArray(Charsets.UTF_8))
|
val member = JournalManager.Member(memberEmail!!, "placeholder".toByteArray())
|
||||||
journalsManager.deleteMember(journal, member)
|
journalsManager.deleteMember(journal, member)
|
||||||
|
|
||||||
return RemoveResult(null)
|
return RemoveResult(null)
|
||||||
|
@ -44,11 +44,11 @@ class EncryptionTest {
|
|||||||
val cryptoManager = Crypto.CryptoManager(1, Helpers.keyBase64, "TestSaltShouldBeJournalId")
|
val cryptoManager = Crypto.CryptoManager(1, Helpers.keyBase64, "TestSaltShouldBeJournalId")
|
||||||
|
|
||||||
val clearText = "This Is Some Test Cleartext."
|
val clearText = "This Is Some Test Cleartext."
|
||||||
val cipher = cryptoManager.encrypt(clearText.toByteArray(Charsets.UTF_8))
|
val cipher = cryptoManager.encrypt(clearText.toByteArray())
|
||||||
assertEquals(clearText, String(cryptoManager.decrypt(cipher!!)!!, Charsets.UTF_8))
|
assertEquals(clearText, String(cryptoManager.decrypt(cipher!!)!!))
|
||||||
|
|
||||||
val expected = "Lz+HUFzh1HdjxuGdQrBwBG1IzHT0ug6mO8fwePSbXtc="
|
val expected = "Lz+HUFzh1HdjxuGdQrBwBG1IzHT0ug6mO8fwePSbXtc="
|
||||||
assertEquals(expected, Base64.encodeToString(cryptoManager.hmac("Some test data".toByteArray(Charsets.UTF_8)), Base64.NO_WRAP))
|
assertEquals(expected, Base64.encodeToString(cryptoManager.hmac("Some test data".toByteArray()), Base64.NO_WRAP))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -57,11 +57,11 @@ class EncryptionTest {
|
|||||||
val cryptoManager = Crypto.CryptoManager(2, Helpers.keyBase64, "TestSaltShouldBeJournalId")
|
val cryptoManager = Crypto.CryptoManager(2, Helpers.keyBase64, "TestSaltShouldBeJournalId")
|
||||||
|
|
||||||
val clearText = "This Is Some Test Cleartext."
|
val clearText = "This Is Some Test Cleartext."
|
||||||
val cipher = cryptoManager.encrypt(clearText.toByteArray(Charsets.UTF_8))
|
val cipher = cryptoManager.encrypt(clearText.toByteArray())
|
||||||
assertEquals(clearText, String(cryptoManager.decrypt(cipher!!)!!, Charsets.UTF_8))
|
assertEquals(clearText, String(cryptoManager.decrypt(cipher!!)!!))
|
||||||
|
|
||||||
val expected = "XQ/A0gentOaE98R9wzf3zEIAHj4OH1GF8J4C6JiJupo="
|
val expected = "XQ/A0gentOaE98R9wzf3zEIAHj4OH1GF8J4C6JiJupo="
|
||||||
assertEquals(expected, Base64.encodeToString(cryptoManager.hmac("Some test data".toByteArray(Charsets.UTF_8)), Base64.NO_WRAP))
|
assertEquals(expected, Base64.encodeToString(cryptoManager.hmac("Some test data".toByteArray()), Base64.NO_WRAP))
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = Exceptions.VersionTooNewException::class)
|
@Test(expected = Exceptions.VersionTooNewException::class)
|
||||||
@ -82,13 +82,13 @@ class EncryptionTest {
|
|||||||
val keyPair = Crypto.generateKeyPair()
|
val keyPair = Crypto.generateKeyPair()
|
||||||
val cryptoManager = Crypto.AsymmetricCryptoManager(keyPair!!)
|
val cryptoManager = Crypto.AsymmetricCryptoManager(keyPair!!)
|
||||||
|
|
||||||
val clearText = "This Is Some Test Cleartext.".toByteArray(Charsets.UTF_8)
|
val clearText = "This Is Some Test Cleartext.".toByteArray()
|
||||||
val cipher = cryptoManager.encrypt(keyPair.publicKey, clearText)
|
val cipher = cryptoManager.encrypt(keyPair.publicKey, clearText)
|
||||||
val clearText2 = cryptoManager.decrypt(cipher!!)
|
val clearText2 = cryptoManager.decrypt(cipher!!)
|
||||||
assertArrayEquals(clearText, clearText2)
|
assertArrayEquals(clearText, clearText2)
|
||||||
|
|
||||||
// Mostly for coverage. Make sure it's the expected sha256 value.
|
// Mostly for coverage. Make sure it's the expected sha256 value.
|
||||||
assertEquals("ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb",
|
assertEquals("ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb",
|
||||||
Hex.toHexString(Crypto.AsymmetricCryptoManager.getKeyFingerprint("a".toByteArray(Charsets.UTF_8))).toLowerCase())
|
Hex.toHexString(Crypto.AsymmetricCryptoManager.getKeyFingerprint("a".toByteArray())).toLowerCase())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ class ServiceTest {
|
|||||||
assertArrayEquals(userInfo.getContent(cryptoManager), userInfo2!!.getContent(cryptoManager))
|
assertArrayEquals(userInfo.getContent(cryptoManager), userInfo2!!.getContent(cryptoManager))
|
||||||
|
|
||||||
// Update
|
// Update
|
||||||
userInfo.setContent(cryptoManager, "test".toByteArray(Charsets.UTF_8))
|
userInfo.setContent(cryptoManager, "test".toByteArray())
|
||||||
manager.update(userInfo)
|
manager.update(userInfo)
|
||||||
userInfo2 = manager[Helpers.USER]
|
userInfo2 = manager[Helpers.USER]
|
||||||
assertNotNull(userInfo2)
|
assertNotNull(userInfo2)
|
||||||
@ -260,7 +260,7 @@ class ServiceTest {
|
|||||||
assertEquals(journalManager.listMembers(journal).size.toLong(), 0)
|
assertEquals(journalManager.listMembers(journal).size.toLong(), 0)
|
||||||
|
|
||||||
// Test inviting ourselves
|
// Test inviting ourselves
|
||||||
val member = JournalManager.Member(Helpers.USER, "test".toByteArray(Charsets.UTF_8))
|
val member = JournalManager.Member(Helpers.USER, "test".toByteArray())
|
||||||
try {
|
try {
|
||||||
caught = null
|
caught = null
|
||||||
journalManager.addMember(journal, member)
|
journalManager.addMember(journal, member)
|
||||||
@ -270,7 +270,7 @@ class ServiceTest {
|
|||||||
|
|
||||||
assertNotNull(caught)
|
assertNotNull(caught)
|
||||||
|
|
||||||
val member2 = JournalManager.Member(Helpers.USER2, "test".toByteArray(Charsets.UTF_8))
|
val member2 = JournalManager.Member(Helpers.USER2, "test".toByteArray())
|
||||||
journalManager.addMember(journal, member2)
|
journalManager.addMember(journal, member2)
|
||||||
assertEquals(journalManager.listMembers(journal).size.toLong(), 1)
|
assertEquals(journalManager.listMembers(journal).size.toLong(), 1)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user