Merge pull request #2635 from nextcloud/chore/noid/spotbugsBadPractice

Spotbugs: fix all bad practice warnings
This commit is contained in:
Marcel Hibbe 2022-12-19 13:42:37 +01:00 committed by GitHub
commit 349844391e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 5 deletions

View file

@ -30,6 +30,7 @@ import com.nextcloud.talk.databinding.RvItemTitleHeaderBinding;
import com.nextcloud.talk.ui.theme.ViewThemeUtils;
import java.util.List;
import java.util.Objects;
import eu.davidea.flexibleadapter.FlexibleAdapter;
import eu.davidea.flexibleadapter.items.AbstractHeaderItem;
@ -63,6 +64,11 @@ public class GenericTextHeaderItem extends AbstractHeaderItem<GenericTextHeaderI
return false;
}
@Override
public int hashCode() {
return Objects.hash(title);
}
@Override
public int getLayoutRes() {
return R.layout.rv_item_title_header;

View file

@ -39,6 +39,7 @@ import com.nextcloud.talk.ui.theme.ViewThemeUtils;
import com.nextcloud.talk.utils.DisplayUtils;
import java.util.List;
import java.util.Objects;
import java.util.regex.Pattern;
import androidx.constraintlayout.widget.ConstraintLayout;
@ -108,6 +109,11 @@ public class MentionAutocompleteItem extends AbstractFlexibleItem<ParticipantIte
return false;
}
@Override
public int hashCode() {
return Objects.hash(objectId, displayName);
}
@Override
public int getLayoutRes() {
return R.layout.rv_item_conversation_info_participant;

View file

@ -24,11 +24,12 @@ package com.nextcloud.talk.utils.ssl;
import android.content.Context;
import android.util.Log;
import com.nextcloud.talk.application.NextcloudTalkApplication;
import com.nextcloud.talk.events.CertificateEvent;
import org.greenrobot.eventbus.EventBus;
import javax.net.ssl.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@ -37,6 +38,13 @@ import java.security.KeyStoreException;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLPeerUnverifiedException;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
public class MagicTrustManager implements X509TrustManager {
private static final String TAG = "MagicTrustManager";
@ -49,9 +57,8 @@ public class MagicTrustManager implements X509TrustManager {
keystoreFile = new File(NextcloudTalkApplication.Companion.getSharedApplication().getDir("CertsKeystore",
Context.MODE_PRIVATE), "keystore.bks");
try {
try (FileInputStream fileInputStream = new FileInputStream(keystoreFile)) {
trustedKeyStore = KeyStore.getInstance(KeyStore.getDefaultType());
FileInputStream fileInputStream = new FileInputStream(keystoreFile);
trustedKeyStore.load(fileInputStream, null);
} catch (Exception exception) {
try {
@ -126,9 +133,8 @@ public class MagicTrustManager implements X509TrustManager {
public void addCertInTrustStore(X509Certificate x509Certificate) {
if (trustedKeyStore != null) {
try {
try (FileOutputStream fileOutputStream = new FileOutputStream(keystoreFile)) {
trustedKeyStore.setCertificateEntry(x509Certificate.getSubjectDN().getName(), x509Certificate);
FileOutputStream fileOutputStream = new FileOutputStream(keystoreFile);
trustedKeyStore.store(fileOutputStream, null);
} catch (Exception exception) {
Log.d(TAG, "Failed to set certificate entry " + exception.getLocalizedMessage());